]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: debug: Do not allocate context when we don't need one
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 17 Nov 2026 09:56:32 +0000 (10:56 +0100)
committerOlivier Houchard <cognet@ci0.org>
Tue, 17 Nov 2026 09:44:59 +0000 (10:44 +0100)
In debug_parse_cli_sched(), when debug dev sched has been used with a
count of 0, do not bother allocating a context, as it will never be
used, and the memory will be leaked.

This is a minor problem that only affects a debug command used
incorrectly, and do not need any backport.

This was submitted by Alexandre Laroche, and should fix github issue

src/debug.c

index 553ffe2d4f21cd514ae0f6a05b7e0f47bf5dafb0..09f09de0a6a43cc655c1dfc065e1f380d1b3439d 100644 (file)
@@ -1955,6 +1955,9 @@ static int debug_parse_cli_sched(char **args, char *payload, struct appctx *appc
                        *(uint8_t *)ptr = new;
        }
 
+       if (count == 0)
+               return cli_err(appctx, "count must be at least 1.\n");
+
        tctx = calloc(count + 2, sizeof(*tctx));
        if (!tctx)
                goto fail;