]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mworker: fix segv in early failure of mworker mode with peers
authorWilliam Lallemand <wlallemand@haproxy.org>
Wed, 7 Dec 2022 14:21:24 +0000 (15:21 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Wed, 7 Dec 2022 14:27:36 +0000 (15:27 +0100)
During an early failure of the mworker mode, the
mworker_cleanlisteners() function is called and tries to cleanup the
peers, however the peers are in a semi-initialized state and will use
NULL pointers.

The fix check the variable before trying to use them.

Bug revealed in issue #1956.

Could be backported as far as 2.0.

src/mworker.c

index fc4dee104c57c23f745549b2ea074598fd8c2b57..90e96158db642ba0e2f7b81e3f5feb51c1a4716d 100644 (file)
@@ -467,8 +467,10 @@ void mworker_cleanlisteners()
 
                stop_proxy(curpeers->peers_fe);
                /* disable this peer section so that it kills itself */
-               signal_unregister_handler(curpeers->sighandler);
-               task_destroy(curpeers->sync_task);
+               if (curpeers->sighandler)
+                       signal_unregister_handler(curpeers->sighandler);
+               if (curpeers->sync_task)
+                       task_destroy(curpeers->sync_task);
                curpeers->sync_task = NULL;
                task_destroy(curpeers->peers_fe->task);
                curpeers->peers_fe->task = NULL;