Given the following example configuration:

    frontend foo
        mode http
        bind *:8080
        unique-id-format x

Running a configuration check with valgrind reports:

    ==30712== 42 (40 direct, 2 indirect) bytes in 1 blocks are definitely lost 
in loss record 18 of 39
    ==30712==    at 0x4C2FB55: calloc (in 
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==30712==    by 0x4ED7E9: add_to_logformat_list (log.c:462)
    ==30712==    by 0x4EEE28: parse_logformat_string (log.c:720)
    ==30712==    by 0x47B09A: check_config_validity (cfgparse.c:3046)
    ==30712==    by 0x52881D: init (haproxy.c:2121)
    ==30712==    by 0x41F382: main (haproxy.c:3126)

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 | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/haproxy.c b/src/haproxy.c
index 215c68a30..818cf3504 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -2698,6 +2698,13 @@ void deinit(void)
                        free(lf);
                }
 
+               list_for_each_entry_safe(lf, lfb, &p->format_unique_id, list) {
+                       LIST_DEL(&lf->list);
+                       release_sample_expr(lf->expr);
+                       free(lf->arg);
+                       free(lf);
+               }
+
                deinit_act_rules(&p->tcp_req.inspect_rules);
                deinit_act_rules(&p->tcp_rep.inspect_rules);
                deinit_act_rules(&p->tcp_req.l4_rules);
-- 
2.27.0


Reply via email to