Given the following example configuration:

    listen http
        bind *:80
        mode http
        stats scope .

Running a configuration check with valgrind reports:

    ==16341== 26 (24 direct, 2 indirect) bytes in 1 blocks are definitely lost 
in loss record 3 of 13
    ==16341==    at 0x4C2FB55: calloc (in 
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==16341==    by 0x571C2E: stats_add_scope (uri_auth.c:296)
    ==16341==    by 0x46CE29: cfg_parse_listen (cfgparse-listen.c:1901)
    ==16341==    by 0x45A112: readcfgfile (cfgparse.c:2078)
    ==16341==    by 0x50A0F5: init (haproxy.c:1828)
    ==16341==    by 0x418248: main (haproxy.c:3012)

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

diff --git a/src/haproxy.c b/src/haproxy.c
index e8cbdf410..5ae21824a 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -2637,6 +2637,8 @@ void deinit(void)
        }/* end while(p) */
 
        while (ua) {
+               struct stat_scope *scope, *scopep;
+
                uap = ua;
                ua = ua->next;
 
@@ -2648,6 +2650,15 @@ void deinit(void)
                userlist_free(uap->userlist);
                deinit_act_rules(&uap->http_req_rules);
 
+               scope = uap->scope;
+               while (scope) {
+                       scopep = scope;
+                       scope = scope->next;
+
+                       free(scopep->px_id);
+                       free(scopep);
+               }
+
                free(uap);
        }
 
-- 
2.28.0


Reply via email to