]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: debug: handle a possible strdup() failure
authorIlia Shipitsin <chipitsine@gmail.com>
Mon, 23 Dec 2024 21:01:22 +0000 (22:01 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 25 Dec 2024 11:42:33 +0000 (12:42 +0100)
This defect was found by the coccinelle script "unchecked-strdup.cocci".
It can be backported to all supported branches.

src/debug.c

index 2987d36ef0011b60338c5b47cf1283cb0754920f..3b15007b88fbb8e35418d1b43f7289bea6b93e1c 100644 (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]) {
                        ha_free(&ctx->match);
                        ctx->match = strdup(args[arg + 1]);
+                       if (!ctx->match)
+                               return cli_err(appctx, "Out of memory.\n");
                        arg++;
                        continue;
                }