prevent double free

This commit is contained in:
Jeff Becker 2016-09-03 16:29:50 -04:00
parent d336d920e8
commit 82f46464f3
No known key found for this signature in database
GPG Key ID: AB950234D6EA286B
2 changed files with 9 additions and 3 deletions

View File

@ -205,12 +205,12 @@ namespace datagram
if(lease) if(lease)
{ {
if(tunnel) if(tunnel)
return DatagramSession::Info{new i2p::data::IdentHash(lease->tunnelGateway.data()), new i2p::data::IdentHash(tunnel->GetEndpointIdentHash().data()), m_LastUse, m_LastSuccess}; return DatagramSession::Info{lease->tunnelGateway, tunnel->GetEndpointIdentHash(), m_LastUse, m_LastSuccess};
else else
return DatagramSession::Info{new i2p::data::IdentHash(lease->tunnelGateway.data()), nullptr, m_LastUse, m_LastSuccess}; return DatagramSession::Info{lease->tunnelGateway, nullptr, m_LastUse, m_LastSuccess};
} }
else if(tunnel) else if(tunnel)
return DatagramSession::Info{nullptr, new i2p::data::IdentHash(tunnel->GetEndpointIdentHash().data()), m_LastUse, m_LastSuccess}; return DatagramSession::Info{nullptr, tunnel->GetEndpointIdentHash(), m_LastUse, m_LastSuccess};
else else
return DatagramSession::Info{nullptr, nullptr, m_LastUse, m_LastSuccess}; return DatagramSession::Info{nullptr, nullptr, m_LastUse, m_LastSuccess};
} }

View File

@ -52,6 +52,12 @@ namespace datagram
const i2p::data::IdentHash * OBEP; const i2p::data::IdentHash * OBEP;
const uint64_t activity; const uint64_t activity;
const uint64_t success; const uint64_t success;
Info() : IBGW(nullptr), OBEP(nullptr), activity(0), success(0) {}
Info(const i2p::data::IdentHash & ibgw, const i2p::data::IdentHash & obep, const uint64_t a, const uint64_t s) :
IBGW(new i2p::data::IdentHash(ibgw.data())),
OBEP(new i2p::data::IdentHash(obep.data())),
activity(a),
success(s) {}
~Info() ~Info()
{ {
if(IBGW) delete IBGW; if(IBGW) delete IBGW;