Browse Source

fixed potential memory leak

pull/189/head
orignal 10 years ago
parent
commit
5d2f9f9f0b
  1. 22
      Transports.cpp

22
Transports.cpp

@ -226,11 +226,20 @@ namespace transport @@ -226,11 +226,20 @@ namespace transport
auto it = m_Peers.find (ident);
if (it == m_Peers.end ())
{
bool connected = false;
try
{
auto r = netdb.FindRouter (ident);
it = m_Peers.insert (std::pair<i2p::data::IdentHash, Peer>(ident, { 0, r, nullptr,
i2p::util::GetSecondsSinceEpoch () })).first;
if (!ConnectToPeer (ident, it->second))
connected= ConnectToPeer (ident, it->second);
}
catch (std::exception& ex)
{
LogPrint (eLogError, "Transports::PostMessage ", ex.what ());
}
if (!connected)
{
DeleteI2NPMessage (msg);
return;
@ -253,11 +262,20 @@ namespace transport @@ -253,11 +262,20 @@ namespace transport
}
auto it = m_Peers.find (ident);
if (it == m_Peers.end ())
{
bool connected = false;
try
{
auto r = netdb.FindRouter (ident);
it = m_Peers.insert (std::pair<i2p::data::IdentHash, Peer>(ident, { 0, r, nullptr,
i2p::util::GetSecondsSinceEpoch () })).first;
if (!ConnectToPeer (ident, it->second))
connected = ConnectToPeer (ident, it->second);
}
catch (std::exception& ex)
{
LogPrint (eLogError, "Transports::PostMessages ", ex.what ());
}
if (!connected)
{
for (auto it1: msgs)
DeleteI2NPMessage (it1);

Loading…
Cancel
Save