]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: log: fix risk of null deref on error path
authorWilly Tarreau <w@1wt.eu>
Tue, 27 Oct 2020 09:35:32 +0000 (10:35 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 27 Oct 2020 09:35:32 +0000 (10:35 +0100)
Previous commit ae32ac74db ("BUG/MINOR: log: fix memory leak on logsrv
parse error") addressed one issue and introduced another one, the logsrv
pointer may also be null at the end of the function so we must test it
before deciding to dereference it.

This should be backported along with the patch above to 2.2.

src/log.c

index 55fa4d51ae948abaa48ca4354cfb687af352898d..c6ba5e635da186f58dd772ed44bdf8d71ad58eb7 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1039,7 +1039,8 @@ int parse_logsrv(char **args, struct list *logsrvs, int do_del, char **err)
 
   error:
        free(smp_rgs);
-       free(logsrv->ring_name);
+       if (logsrv)
+               free(logsrv->ring_name);
        free(logsrv);
        return 0;
 }