From fab9a67d23b183e9ee98ad2e876e4fc1a138e31e Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Mon, 30 Nov 2020 18:49:38 +0100 Subject: [PATCH] Guard against NULL Sockets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I’ve not been able to reproduce it always, but when using wxHTTP the internal socket was sometimes already closed. So just guard against crashes. --- src/osx/core/sockosx.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/osx/core/sockosx.cpp b/src/osx/core/sockosx.cpp index f6301c28ca..3f0c842179 100644 --- a/src/osx/core/sockosx.cpp +++ b/src/osx/core/sockosx.cpp @@ -263,7 +263,8 @@ void wxSocketManagerMac::Install_Callback(wxSocketImpl *socket_, { wxSocketImplMac * const socket = static_cast(socket_); - CFSocketEnableCallBacks(socket->GetSocket(), GetCFCallback(socket, event)); + if ( socket->GetSocket() ) + CFSocketEnableCallBacks(socket->GetSocket(), GetCFCallback(socket, event)); } void wxSocketManagerMac::Uninstall_Callback(wxSocketImpl *socket_, @@ -271,7 +272,8 @@ void wxSocketManagerMac::Uninstall_Callback(wxSocketImpl *socket_, { wxSocketImplMac * const socket = static_cast(socket_); - CFSocketDisableCallBacks(socket->GetSocket(), GetCFCallback(socket, event)); + if ( socket->GetSocket() ) + CFSocketDisableCallBacks(socket->GetSocket(), GetCFCallback(socket, event)); } // set the wxBase variable to point to CF wxSocketManager implementation so