BUG/MINOR: log: fix potential memory leak upon error in add_to_logformat_list()
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 4 Sep 2025 08:26:37 +0000 (10:26 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 1 Oct 2025 14:48:34 +0000 (16:48 +0200)
commit55078fc88ea237b02ad2033489d29dd2ce3cac08
treeb4d1151c67e4af8f4209f3741b0b1ce9e01e70ae
parentb75067264125f1ef17c395b026bc6b6fa350fec9
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.

(cherry picked from commit c97ced3f938271c9d648594d6c4bfcd194c36a7d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 5d0cd28ce889a85fb4ef8d1617f8f61abd1ebea7)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 9ac6454aa1ebcb813f61f7b4fb6ac07dbb21d7ec)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/log.c