From e901307d8da322c41b5617dbe0e7e551d7c66fbd Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 15 Feb 2015 10:23:06 -0500 Subject: [PATCH] fixed crash --- Transports.cpp | 11 +++++------ Transports.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Transports.cpp b/Transports.cpp index 1340d8f5..47839a1c 100644 --- a/Transports.cpp +++ b/Transports.cpp @@ -342,13 +342,13 @@ namespace transport } void Transports::HandleNTCPResolve (const boost::system::error_code& ecode, boost::asio::ip::tcp::resolver::iterator it, - const i2p::data::IdentHash& ident, std::shared_ptr resolver) + i2p::data::IdentHash ident, std::shared_ptr resolver) { auto it1 = m_Peers.find (ident); - if (it1 != m_Peers.end () && it1->second.router) + if (it1 != m_Peers.end ()) { auto& peer = it1->second; - if (!ecode) + if (!ecode && peer.router) { auto address = (*it).endpoint ().address (); LogPrint (eLogInfo, (*it).host_name (), " has been resolved to ", address); @@ -360,10 +360,9 @@ namespace transport return; } } + LogPrint (eLogError, "Unable to resolve NTCP address: ", ecode.message ()); + m_Peers.erase (it1); } - - LogPrint (eLogError, "Unable to resolve NTCP address: ", ecode.message ()); - m_Peers.erase (it1); } void Transports::CloseSession (std::shared_ptr router) diff --git a/Transports.h b/Transports.h index e1c85374..208eeece 100644 --- a/Transports.h +++ b/Transports.h @@ -101,7 +101,7 @@ namespace transport void NTCPResolve (const std::string& addr, const i2p::data::IdentHash& ident); void HandleNTCPResolve (const boost::system::error_code& ecode, boost::asio::ip::tcp::resolver::iterator it, - const i2p::data::IdentHash& ident, std::shared_ptr resolver); + i2p::data::IdentHash ident, std::shared_ptr resolver); void DetectExternalIP ();