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.
This commit is contained in:
Ilia Shipitsin 2024-12-27 21:45:32 +01:00 committed by Willy Tarreau
parent caf60ac696
commit b4f965be9e

View File

@ -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;
}
/*