From 6fb74a1dc3e7aeb1092be05a46bbb75e2638e0aa Mon Sep 17 00:00:00 2001 From: Tim Duesterhus Date: Sat, 4 Jul 2020 11:49:43 +0200 Subject: [PATCH] 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. --- src/haproxy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/haproxy.c b/src/haproxy.c index 9d97d48d0..65067f249 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -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); }