Browse Source

prevent double free

pull/628/head
Jeff Becker 8 years ago
parent
commit
82f46464f3
No known key found for this signature in database
GPG Key ID: AB950234D6EA286B
  1. 6
      Datagram.cpp
  2. 6
      Datagram.h

6
Datagram.cpp

@ -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};
} }

6
Datagram.h

@ -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;

Loading…
Cancel
Save