BUG/MEDIUM: mworker: fix segv in early failure of mworker mode with peers

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.
This commit is contained in:
William Lallemand 2022-12-07 15:21:24 +01:00
parent 40db4ae8bb
commit 035058e8bf

View 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;