Given the following example configuration:

    backend foo
        mode http
        use-server %[str(x)] if { always_true }
        server x example.com:80

Running a configuration check with valgrind reports:

    ==19376== 170 (40 direct, 130 indirect) bytes in 1 blocks are definitely 
lost in loss record 281 of 347
    ==19376==    at 0x4C2FB55: calloc (in 
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==19376==    by 0x5091AC: add_sample_to_logformat_list (log.c:511)
    ==19376==    by 0x50A5A6: parse_logformat_string (log.c:671)
    ==19376==    by 0x4957F2: check_config_validity (cfgparse.c:2588)
    ==19376==    by 0x54442D: init (haproxy.c:2129)
    ==19376==    by 0x421E42: main (haproxy.c:3169)

After this patch is applied the leak is gone as expected.

This is a very minor leak that can only be observed if deinit() is called,
shortly before the OS will free all memory of the process anyway. No
backport needed.
---
 src/haproxy.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/haproxy.c b/src/haproxy.c
index 2e248d7eb..53301c0be 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -2665,6 +2665,12 @@ void deinit(void)
                list_for_each_entry_safe(srule, sruleb, &p->server_rules, list) 
{
                        LIST_DEL(&srule->list);
                        prune_acl_cond(srule->cond);
+                       list_for_each_entry_safe(lf, lfb, &srule->expr, list) {
+                               LIST_DEL(&lf->list);
+                               release_sample_expr(lf->expr);
+                               free(lf->arg);
+                               free(lf);
+                       }
                        free(srule->file);
                        free(srule->cond);
                        free(srule);
-- 
2.27.0


Reply via email to