From 5cd74d0e266bdec0de6e7463126220bc8f3722e8 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 22 Apr 2026 12:38:53 -0400 Subject: duplicate_delivery: handle error conditions * but also memcpy might not be enough here --- src/lib/delivery/delivery.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lib/delivery/delivery.c b/src/lib/delivery/delivery.c index e32a805..5403743 100644 --- a/src/lib/delivery/delivery.c +++ b/src/lib/delivery/delivery.c @@ -62,10 +62,20 @@ struct Delivery *delivery_duplicate(const struct Delivery *ctx) { memcpy(&result->rules.content, &ctx->rules.content, sizeof(ctx->rules.content)); if (ctx->rules._handle) { - /* + SYSDEBUG("%s", "duplicating INIFILE handle - BEGIN"); result->rules._handle = malloc(sizeof(*result->rules._handle)); - result->rules._handle->section = malloc(result->rules._handle->section_count * sizeof(*result->rules._handle->section)); + if (!result->rules._handle) { + SYSERROR("%s", "unable to allocate space for INIFILE handle"); + return NULL; + } + result->rules._handle->section = malloc(ctx->rules._handle->section_count * sizeof(**ctx->rules._handle->section)); + if (!result->rules._handle->section) { + guard_free(result->rules._handle); + SYSERROR("%s", "unable to allocate space for INIFILE section"); + return NULL; + } memcpy(result->rules._handle, &ctx->rules._handle, sizeof(*ctx->rules._handle)); + SYSDEBUG("%s", "duplicating INIFILE handle - END"); } // Runtime -- cgit