From 28ca7fc594ca643895e2a28bb3e3ed021475a704 Mon Sep 17 00:00:00 2001 From: Valentine Krasnobaeva Date: Fri, 23 Aug 2024 18:54:31 +0200 Subject: [PATCH] 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. --- src/haproxy.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/haproxy.c b/src/haproxy.c index 218040c1a..f7bb5b5d8 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() */ -- 2.47.3