From 5bdd4157d3f9823f9b50bd6846265fbd989c849b Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 6 Jan 2014 12:48:46 +0100 Subject: [PATCH] SecureSocket: avoid crash on close Deleting the BIO while it's still waiting on a read() in another thread will lead to a crash when the socket is eventually closed. Close the socket first, so the read() is unlocked, then safely delete the BIO. --- src/kits/network/libnetapi/SecureSocket.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/kits/network/libnetapi/SecureSocket.cpp b/src/kits/network/libnetapi/SecureSocket.cpp index 280f9737cb..f7eb1489d7 100644 --- a/src/kits/network/libnetapi/SecureSocket.cpp +++ b/src/kits/network/libnetapi/SecureSocket.cpp @@ -107,12 +107,15 @@ BSecureSocket::Disconnect() SSL_CTX_free(fPrivate->fCTX); fPrivate->fCTX = NULL; } + + BSocket::Disconnect(); + // Must do this before freeing the BIO, to make sure any pending + // read or write gets unlocked properly. if (fPrivate->fBIO != NULL) { BIO_free(fPrivate->fBIO); fPrivate->fBIO = NULL; } } - return BSocket::Disconnect(); }