]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: log: fix potential lf->name memory leak
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 22 Feb 2024 14:14:21 +0000 (15:14 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 22 Feb 2024 14:32:42 +0000 (15:32 +0100)
commit2462e5bccab61fc8afd3d8fc6cf5617a47d1726a
tree94111e12a6042bdba114be1972fc6aeb07e33596
parent1c2e16ba8a069ab2d7e116120e74127edb3c7254
BUG/MINOR: log: fix potential lf->name memory leak

Recent commit 2ed6068 ("MINOR: log: custom name for logformat node")
introduced a potential memory leak because when custom name is provided,
lf->name value is allocated using strdup(), thus is expected to be freed
alongside the node when the node is released.

However lf->name was only freed in some common places within log.c
cleanups and helpers func, but in reality there are still cases where
lf nodes are manually freed without making use of freeing helpers.

So this is what this patch does, it makes sure all lf freeing places now
leverage the free_logformat_node() helper function that takes care of
freeing all known allocated elements within the node, including custom
name.

This commit depends on:
 - "MINOR: log: add free_logformat_node() helper function"

No backport needed unless 2ed6068 gets backported.
src/cfgparse.c
src/log.c