diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-22 12:38:53 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-22 12:38:53 -0400 |
| commit | 5cd74d0e266bdec0de6e7463126220bc8f3722e8 (patch) | |
| tree | 0e06fa6ddeb51f75ee388eea250930aaeb98e837 /src | |
| parent | 58102ac5a1d8daa16aa623a4ea900a3d1e603947 (diff) | |
| download | stasis-5cd74d0e266bdec0de6e7463126220bc8f3722e8.tar.gz | |
duplicate_delivery: handle error conditions
* but also memcpy might not be enough here
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/delivery/delivery.c | 14 |
1 files 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 |
