Unverified Commit 981c588a authored by Dennis Jenkins's avatar Dennis Jenkins Committed by GitHub

Merge pull request #487 from knowledge4igor/fix_memory_leak_in_using_ssl

Fix memory leak in using ssl
parents 37cbf1f9 364ce2f6
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
Peer(); Peer();
Peer(const Address& addr); Peer(const Address& addr);
~Peer() {} ~Peer();
const Address& address() const; const Address& address() const;
const std::string& hostname() const; const std::string& hostname() const;
......
...@@ -28,6 +28,14 @@ Peer::Peer(const Address& addr) ...@@ -28,6 +28,14 @@ Peer::Peer(const Address& addr)
, ssl_(NULL) , ssl_(NULL)
{ } { }
Peer::~Peer()
{
#ifdef PISTACHE_USE_SSL
if (ssl_)
SSL_free((SSL *)ssl_);
#endif /* PISTACHE_USE_SSL */
}
const Address& Peer::address() const const Address& Peer::address() const
{ {
return addr; return addr;
......
...@@ -182,6 +182,7 @@ Transport::handlePeerDisconnection(const std::shared_ptr<Peer>& peer) { ...@@ -182,6 +182,7 @@ Transport::handlePeerDisconnection(const std::shared_ptr<Peer>& peer) {
#ifdef PISTACHE_USE_SSL #ifdef PISTACHE_USE_SSL
if (peer->ssl() != NULL) { if (peer->ssl() != NULL) {
SSL_free((SSL *)peer->ssl()); SSL_free((SSL *)peer->ssl());
peer->associateSSL(NULL);
} }
#endif /* PISTACHE_USE_SSL */ #endif /* PISTACHE_USE_SSL */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment