BUG/MINOR: debug: 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-23 22:01:22 +01:00 committed by Willy Tarreau
parent a3e6c783cd
commit 6524fbfb70

View File

@ -2048,6 +2048,8 @@ static int debug_parse_cli_memstats(char **args, char *payload, struct appctx *a
else if (strcmp(args[arg], "match") == 0 && *args[arg + 1]) { else if (strcmp(args[arg], "match") == 0 && *args[arg + 1]) {
ha_free(&ctx->match); ha_free(&ctx->match);
ctx->match = strdup(args[arg + 1]); ctx->match = strdup(args[arg + 1]);
if (!ctx->match)
return cli_err(appctx, "Out of memory.\n");
arg++; arg++;
continue; continue;
} }