Skip to content

Commit 26776c7

Browse files
alexanderstephanGarfield96
authored andcommitted
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 <christian.norbert.menges@sap.com>
1 parent aa20905 commit 26776c7

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/tools.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4689,6 +4689,8 @@ char *indent_msg(char **out, int level)
46894689

46904690
needed = 1 + level * (lf + 1) + len + 1;
46914691
p = ret = malloc(needed);
4692+
if (unlikely(!ret))
4693+
return NULL;
46924694
in = *out;
46934695

46944696
/* skip initial LFs */

0 commit comments

Comments
 (0)