mirror of
https://github.com/debauchee/barrier.git
synced 2024-11-26 13:16:18 +03:00
Fix memory leak during socket shutdown
This commit is contained in:
parent
4ec30b6ade
commit
71f2ca7c35
@ -84,16 +84,8 @@ SecureSocket::~SecureSocket()
|
|||||||
// could cause events to get called on a dead object. TCPSocket
|
// could cause events to get called on a dead object. TCPSocket
|
||||||
// will do this, too, but the double-call is harmless
|
// will do this, too, but the double-call is harmless
|
||||||
setJob(NULL);
|
setJob(NULL);
|
||||||
if (m_ssl->m_ssl != NULL) {
|
freeSSLResources();
|
||||||
SSL_shutdown(m_ssl->m_ssl);
|
|
||||||
|
|
||||||
SSL_free(m_ssl->m_ssl);
|
|
||||||
m_ssl->m_ssl = NULL;
|
|
||||||
}
|
|
||||||
if (m_ssl->m_context != NULL) {
|
|
||||||
SSL_CTX_free(m_ssl->m_context);
|
|
||||||
m_ssl->m_context = NULL;
|
|
||||||
}
|
|
||||||
// removing sleep() because I have no idea why you would want to do it
|
// removing sleep() because I have no idea why you would want to do it
|
||||||
// ... smells of trying to cover up a bug you don't understand
|
// ... smells of trying to cover up a bug you don't understand
|
||||||
//ARCH->sleep(1);
|
//ARCH->sleep(1);
|
||||||
@ -104,12 +96,24 @@ void
|
|||||||
SecureSocket::close()
|
SecureSocket::close()
|
||||||
{
|
{
|
||||||
isFatal(true);
|
isFatal(true);
|
||||||
|
freeSSLResources();
|
||||||
SSL_shutdown(m_ssl->m_ssl);
|
|
||||||
|
|
||||||
TCPSocket::close();
|
TCPSocket::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SecureSocket::freeSSLResources()
|
||||||
|
{
|
||||||
|
if (m_ssl->m_ssl != NULL) {
|
||||||
|
SSL_shutdown(m_ssl->m_ssl);
|
||||||
|
SSL_free(m_ssl->m_ssl);
|
||||||
|
m_ssl->m_ssl = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_ssl->m_context != NULL) {
|
||||||
|
SSL_CTX_free(m_ssl->m_context);
|
||||||
|
m_ssl->m_context = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SecureSocket::connect(const NetworkAddress& addr)
|
SecureSocket::connect(const NetworkAddress& addr)
|
||||||
{
|
{
|
||||||
|
@ -88,6 +88,8 @@ private:
|
|||||||
|
|
||||||
void handleTCPConnected(const Event& event, void*);
|
void handleTCPConnected(const Event& event, void*);
|
||||||
|
|
||||||
|
void freeSSLResources();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ssl* m_ssl;
|
Ssl* m_ssl;
|
||||||
bool m_secureReady;
|
bool m_secureReady;
|
||||||
|
Loading…
Reference in New Issue
Block a user