From 26441e0c24040712f59dfb8581e068f847153a9a Mon Sep 17 00:00:00 2001 From: Arne Welzel Date: Fri, 14 Mar 2025 15:37:22 +0100 Subject: [PATCH] cluster/websocket: Fix null deref at WebSocket server shutdown WebSocket clients that connected with the wrong URL do not have a backend attached. If a dispatcher is terminated while these clients are still connected, a null deref would happen. This was found while running all cluster/websocket tests in a loop for a long time, tickling a segfault during the bad-url test. --- src/cluster/websocket/WebSocket.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cluster/websocket/WebSocket.cc b/src/cluster/websocket/WebSocket.cc index 115db9aec8..fa2efb51ae 100644 --- a/src/cluster/websocket/WebSocket.cc +++ b/src/cluster/websocket/WebSocket.cc @@ -231,7 +231,9 @@ void WebSocketEventDispatcher::Terminate() { wsc->getRemotePort()); QueueReply(WebSocketCloseReply{wsc, 1001, "Terminating"}); - backend->Terminate(); + + if ( backend ) + backend->Terminate(); } clients.clear();