mirror of
https://github.com/haproxy/haproxy.git
synced 2026-06-06 23:32:34 -04:00
BUG/MINOR: log: fix potential memory leak upon error in add_to_logformat_list()
As reported on GH #3099, upon memory error add_to_logformat_list() will
return and error but it fails to properly memory which was allocated
within the function, which could result in memory leak.
Let's free all relevant variables allocated by the function before returning.
No backport needed unless 22ac1f5ee ("("BUG/MINOR: log: Add OOM checks for
calloc() and malloc() in logformat parser and dup_logger()") is.
This commit is contained in:
parent
842f32f3f1
commit
c97ced3f93
1 changed files with 2 additions and 0 deletions
|
|
@ -575,6 +575,8 @@ int add_to_logformat_list(char *start, char *end, int type, struct lf_expr *lf_e
|
|||
struct logformat_node *node = calloc(1, sizeof(*node));
|
||||
str = calloc(1, end - start + 1);
|
||||
if (unlikely(!node || !str)) {
|
||||
free(node);
|
||||
free(str);
|
||||
memprintf(err, "out of memory error");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue