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.3-dev8~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26776c7b8f963299585300472a2b29ad39e47943;p=thirdparty%2Fhaproxy.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 --- diff --git a/src/tools.c b/src/tools.c index 4507564bc..1615ef2ae 100644 --- a/src/tools.c +++ b/src/tools.c @@ -4689,6 +4689,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 */