]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: haproxy: Free srule->file during deinit
authorTim Duesterhus <tim@bastelstu.be>
Sat, 4 Jul 2020 09:49:43 +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:

    backend foo
     mode http
     use-server x if { always_true }
     server x example.com:80

Running a configuration check with valgrind reports:

    ==18650== 14 bytes in 1 blocks are definitely lost in loss record 3 of 345
    ==18650==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==18650==    by 0x649E489: strdup (strdup.c:42)
    ==18650==    by 0x4A5438: cfg_parse_listen (cfgparse-listen.c:1548)
    ==18650==    by 0x494C59: readcfgfile (cfgparse.c:2049)
    ==18650==    by 0x5450B5: init (haproxy.c:2029)
    ==18650==    by 0x421E42: main (haproxy.c:3168)

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 9d97d48d01a1316fed99b6924e27fbc589b217f3..65067f24912cb4fe9e8649f08345220c1ee7e443 100644 (file)
@@ -2666,6 +2666,7 @@ void deinit(void)
                list_for_each_entry_safe(srule, sruleb, &p->server_rules, list) {
                        LIST_DEL(&srule->list);
                        prune_acl_cond(srule->cond);
+                       free(srule->file);
                        free(srule->cond);
                        free(srule);
                }