Skip to content

Commit

Permalink
Merge pull request #1011 from paullouisageneau/fix-mbedtls-tlstranspo…
Browse files Browse the repository at this point in the history
…rt-destructor

Fix memory leak in TlsTransport with MbedTLS
  • Loading branch information
paullouisageneau authored Oct 21, 2023
2 parents 67e081f + c605f34 commit 0e5e240
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/impl/tlstransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ TlsTransport::TlsTransport(variant<shared_ptr<TcpTransport>, shared_ptr<HttpProx

TlsTransport::~TlsTransport() {
stop();

PLOG_DEBUG << "Destroying TLS transport";
gnutls_deinit(mSession);
}

Expand Down Expand Up @@ -354,7 +356,15 @@ TlsTransport::TlsTransport(variant<shared_ptr<TcpTransport>, shared_ptr<HttpProx
}
}

TlsTransport::~TlsTransport() {}
TlsTransport::~TlsTransport() {
stop();

PLOG_DEBUG << "Destroying TLS transport";
mbedtls_entropy_free(&mEntropy);
mbedtls_ctr_drbg_free(&mDrbg);
mbedtls_ssl_free(&mSsl);
mbedtls_ssl_config_free(&mConf);
}

void TlsTransport::start() {
PLOG_DEBUG << "Starting TLS transport";
Expand Down Expand Up @@ -630,6 +640,8 @@ TlsTransport::TlsTransport(variant<shared_ptr<TcpTransport>, shared_ptr<HttpProx

TlsTransport::~TlsTransport() {
stop();

PLOG_DEBUG << "Destroying TLS transport";
SSL_free(mSsl);
SSL_CTX_free(mCtx);
}
Expand Down

0 comments on commit 0e5e240

Please sign in to comment.