From: Ilia Shipitsin Date: Fri, 27 Dec 2024 20:45:32 +0000 (+0100) Subject: BUG/MINOR: compression: handle a possible strdup() failure X-Git-Tag: v3.2-dev3~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4f965be9e0585193c6d23ca0ff2839de0980e48;p=thirdparty%2Fhaproxy.git BUG/MINOR: compression: handle a possible strdup() failure This defect was found by the coccinelle script "unchecked-strdup.cocci". It can be backported to all supported branches. --- diff --git a/src/compression.c b/src/compression.c index a4464e09b6..1fe5aec3bf 100644 --- a/src/compression.c +++ b/src/compression.c @@ -116,12 +116,19 @@ int comp_append_type(struct comp_type **types, const char *type) comp_type = calloc(1, sizeof(*comp_type)); if (!comp_type) - return 1; + goto fail; comp_type->name_len = strlen(type); comp_type->name = strdup(type); + if (!comp_type->name) + goto fail_free_comp_type; comp_type->next = *types; *types = comp_type; return 0; + +fail_free_comp_type: + free(comp_type); +fail: + return 1; } /*