aboutsummaryrefslogtreecommitdiff
path: root/src/lib/delivery/delivery_populate.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2025-02-04 13:06:11 -0500
committerGitHub <noreply@github.com>2025-02-04 13:06:11 -0500
commit89bd28eb5ac263d1753021f25e1bc62f48e7008d (patch)
tree622918f9a81723b830ab8bcc403154271932b591 /src/lib/delivery/delivery_populate.c
parent2372e40c40ef7bc85176d8998272ad75a59fcf05 (diff)
parent825aa472739775a5e2d673043f9d846df1eac924 (diff)
downloadstasis-89bd28eb5ac263d1753021f25e1bc62f48e7008d.tar.gz
Merge pull request #86 from jhunkeler/memfixes
ASAN: Fix leaks
Diffstat (limited to 'src/lib/delivery/delivery_populate.c')
-rw-r--r--src/lib/delivery/delivery_populate.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/lib/delivery/delivery_populate.c b/src/lib/delivery/delivery_populate.c
index e9aea89..63df9fd 100644
--- a/src/lib/delivery/delivery_populate.c
+++ b/src/lib/delivery/delivery_populate.c
@@ -30,11 +30,21 @@ int populate_info(struct Delivery *ctx) {
if (!ctx->info.time_str_epoch) {
// Record timestamp used for release
time(&ctx->info.time_now);
- ctx->info.time_info = localtime(&ctx->info.time_now);
+ if (!ctx->info.time_info) {
+ ctx->info.time_info = malloc(sizeof(*ctx->info.time_info));
+ if (!ctx->info.time_info) {
+ msg(STASIS_MSG_ERROR, "%s: Unable to allocate memory for time_info\n", strerror(errno));
+ return -1;
+ }
+ if (!localtime_r(&ctx->info.time_now, ctx->info.time_info)) {
+ msg(STASIS_MSG_ERROR, "%s: localtime_r failed\n", strerror(errno));
+ return -1;
+ }
+ }
ctx->info.time_str_epoch = calloc(STASIS_TIME_STR_MAX, sizeof(*ctx->info.time_str_epoch));
if (!ctx->info.time_str_epoch) {
- msg(STASIS_MSG_ERROR, "Unable to allocate memory for Unix epoch string\n");
+ msg(STASIS_MSG_ERROR, "%s: Unable to allocate memory for Unix epoch string\n", strerror(errno));
return -1;
}
snprintf(ctx->info.time_str_epoch, STASIS_TIME_STR_MAX - 1, "%li", ctx->info.time_now);