BUG/MINOR: pool: 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:55:07 +01:00 committed by Willy Tarreau
parent b4f965be9e
commit beca953c55

View File

@ -1373,6 +1373,8 @@ static int cli_parse_show_pools(char **args, char *payload, struct appctx *appct
} }
else if (strcmp(args[arg], "match") == 0 && *args[arg+1]) { else if (strcmp(args[arg], "match") == 0 && *args[arg+1]) {
ctx->prefix = strdup(args[arg+1]); // only pools starting with this ctx->prefix = strdup(args[arg+1]); // only pools starting with this
if (!ctx->prefix)
return cli_err(appctx, "Out of memory.\n");
arg++; arg++;
} }
else if (isdigit((unsigned char)*args[arg])) { else if (isdigit((unsigned char)*args[arg])) {