BUG/MINOR: haproxy: Free uri_auth->scope during deinit

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.
This commit is contained in:
Tim Duesterhus 2020-09-10 19:46:38 +02:00 committed by Willy Tarreau
parent 022e5e56ed
commit 00f00cf8fd

View File

@ -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);
}