From: Tim Duesterhus Date: Tue, 26 Apr 2022 21:28:47 +0000 (+0200) Subject: BUG/MINOR: resolvers: Fix memory leak in resolvers_deinit() X-Git-Tag: v2.6-dev8~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0b7031b37d729c55b7b4390f3c8328201654e0d7;p=thirdparty%2Fhaproxy.git BUG/MINOR: resolvers: Fix memory leak in resolvers_deinit() A config like the following: global stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners resolvers unbound nameserver unbound 127.0.0.1:53 will report the following leak when running a configuration check: ==241882== 6,991 (6,952 direct, 39 indirect) bytes in 1 blocks are definitely lost in loss record 8 of 13 ==241882== at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==241882== by 0x25938D: cfg_parse_resolvers (resolvers.c:3193) ==241882== by 0x26A1E8: readcfgfile (cfgparse.c:2171) ==241882== by 0x156D72: init (haproxy.c:2016) ==241882== by 0x156D72: main (haproxy.c:3037) because the `.px` member of `struct resolvers` is not freed. The offending allocation was introduced in c943799c865c04281454a7a54fd6c45c2b4d7e09 which is a reorganization that happened during development of 2.4.x. This fix can likely be backported without issue to 2.4+ and is likely not needed for earlier versions as the leak happens during deinit only. --- diff --git a/src/resolvers.c b/src/resolvers.c index 0b7faf93d6..3179073b55 100644 --- a/src/resolvers.c +++ b/src/resolvers.c @@ -2448,6 +2448,7 @@ static void resolvers_deinit(void) abort_resolution(res); } + free_proxy(resolvers->px); free(resolvers->id); free((char *)resolvers->conf.file); task_destroy(resolvers->t);