]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: haproxy: free init_env in deinit only if allocated
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Fri, 23 Aug 2024 16:54:31 +0000 (18:54 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Fri, 23 Aug 2024 17:08:53 +0000 (19:08 +0200)
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

index 218040c1a5bcccdc96bf5393576d99de8caf944d..f7bb5b5d8ca4ee49f4d310eeb715c0e4249ff074 100644 (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() */