From 3039da2cb243b7658f8dc1e875be4ddb2c7ec4a2 Mon Sep 17 00:00:00 2001 From: roytam1 Date: Wed, 27 Dec 2023 19:17:25 +0800 Subject: [PATCH] websocket: workaround of `mSocketThread` use-after-free when application is terminating --- netwerk/protocol/websocket/WebSocketChannel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netwerk/protocol/websocket/WebSocketChannel.cpp b/netwerk/protocol/websocket/WebSocketChannel.cpp index 9fca09a087..ddfe80b24f 100644 --- a/netwerk/protocol/websocket/WebSocketChannel.cpp +++ b/netwerk/protocol/websocket/WebSocketChannel.cpp @@ -2320,6 +2320,10 @@ WebSocketChannel::CleanupConnection() { LOG(("WebSocketChannel::CleanupConnection() %p", this)); + if(!mSocketThread) { // freed elsewhere, give up here + return; + } + // This should run on the Socket Thread to prevent potential races. bool onSocketThread; nsresult rv = mSocketThread->IsOnCurrentThread(&onSocketThread);