From: Valentine Krasnobaeva Date: Fri, 23 Aug 2024 16:54:31 +0000 (+0200) Subject: BUG/MINOR: haproxy: free init_env in deinit only if allocated X-Git-Tag: v3.1-dev7~51 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=28ca7fc594ca643895e2a28bb3e3ed021475a704;p=thirdparty%2Fhaproxy.git BUG/MINOR: haproxy: free init_env in deinit only if allocated This fixes 7b78e1571 (" MINOR: mworker: restore initial env before wait mode"). In cases, when haproxy starts without any configuration, for example: 'haproxy -vv', init_env array to backup env variables is never allocated. So, we need to check in deinit(), when we free its memory, that init_env is not a NULL ptr. --- diff --git a/src/haproxy.c b/src/haproxy.c index 218040c1a5..f7bb5b5d8c 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -2863,11 +2863,13 @@ void deinit(void) deinit_pollers(); /* free env variables backup */ - while (*tmp) { - free(*tmp); - tmp++; + if (init_env) { + while (*tmp) { + free(*tmp); + tmp++; + } + free(init_env); } - free(init_env); } /* end deinit() */