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.
This commit is contained in:
Valentine Krasnobaeva 2024-08-23 18:54:31 +02:00 committed by William Lallemand
parent 7b78e1571b
commit 28ca7fc594
1 changed files with 6 additions and 4 deletions

View File

@ -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() */