From: Alexander Stephan Date: Mon, 1 Sep 2025 10:01:50 +0000 (+0000) Subject: BUG/MINOR: tools: Add OOM check for malloc() in indent_msg() X-Git-Tag: v3.0.12~39 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=883d1f963f81a069f901a5bdfbd477fbc8e8b62d;p=haproxy-3.0.git BUG/MINOR: tools: Add OOM check for malloc() in indent_msg() This patch adds a missing out-of-memory (OOM) check after the call to `malloc()` in `indent_msg()`. If memory allocation fails, the function returns NULL to prevent undefined behavior. Co-authored-by: Christian Norbert Menges (cherry picked from commit 26776c7b8f963299585300472a2b29ad39e47943) Signed-off-by: Christopher Faulet (cherry picked from commit 35c11b9b05b1adbfc75338a08660460458507e6f) Signed-off-by: Christopher Faulet (cherry picked from commit ffbcd48e5af6bcfd25a14ab8bb0553e2954ff0e6) Signed-off-by: Christopher Faulet --- diff --git a/src/tools.c b/src/tools.c index a294fe3..b26ca35 100644 --- a/src/tools.c +++ b/src/tools.c @@ -4559,6 +4559,8 @@ char *indent_msg(char **out, int level) needed = 1 + level * (lf + 1) + len + 1; p = ret = malloc(needed); + if (unlikely(!ret)) + return NULL; in = *out; /* skip initial LFs */