Commit 364ce2f6 authored by knowledge4igor's avatar knowledge4igor

Fix memory leak in using ssl

parent eb59e458
......@@ -38,7 +38,7 @@ public:
Peer();
Peer(const Address& addr);
~Peer() {}
~Peer();
const Address& address() const;
const std::string& hostname() const;
......
......@@ -28,6 +28,14 @@ Peer::Peer(const Address& addr)
, ssl_(NULL)
{ }
Peer::~Peer()
{
#ifdef PISTACHE_USE_SSL
if (ssl_)
SSL_free((SSL *)ssl_);
#endif /* PISTACHE_USE_SSL */
}
const Address& Peer::address() const
{
return addr;
......
......@@ -182,6 +182,7 @@ Transport::handlePeerDisconnection(const std::shared_ptr<Peer>& peer) {
#ifdef PISTACHE_USE_SSL
if (peer->ssl() != NULL) {
SSL_free((SSL *)peer->ssl());
peer->associateSSL(NULL);
}
#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