]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: haproxy: Free proxy->format_unique_id during deinit
authorTim Duesterhus <tim@bastelstu.be>
Sat, 4 Jul 2020 09:49:40 +0000 (11:49 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 7 Jul 2020 14:52:35 +0000 (16:52 +0200)
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

index 6c5566467a42bd7f0387454e9958260ed449ed2e..4b3800ae0c6d1c3b622766164b9348a5e2f9ce89 100644 (file)
@@ -2712,6 +2712,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);