BUG/MINOR: haproxy: Free srule->file during deinit

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.
This commit is contained in:
Tim Duesterhus 2020-07-04 11:49:43 +02:00 committed by Willy Tarreau
parent 18c63591f0
commit 6fb74a1dc3

View File

@ -2666,6 +2666,7 @@ void deinit(void)
list_for_each_entry_safe(srule, sruleb, &p->server_rules, list) { list_for_each_entry_safe(srule, sruleb, &p->server_rules, list) {
LIST_DEL(&srule->list); LIST_DEL(&srule->list);
prune_acl_cond(srule->cond); prune_acl_cond(srule->cond);
free(srule->file);
free(srule->cond); free(srule->cond);
free(srule); free(srule);
} }