mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-16 22:16:36 +02:00
fixed potential memory leak
This commit is contained in:
parent
3987d5e5a0
commit
5f8356741e
1 changed files with 24 additions and 15 deletions
11
SSU.cpp
11
SSU.cpp
|
@ -217,6 +217,8 @@ namespace transport
|
||||||
for (auto it1: packets)
|
for (auto it1: packets)
|
||||||
{
|
{
|
||||||
auto packet = it1;
|
auto packet = it1;
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!session || session->GetRemoteEndpoint () != packet->from) // we received packet for other session than previous
|
if (!session || session->GetRemoteEndpoint () != packet->from) // we received packet for other session than previous
|
||||||
{
|
{
|
||||||
if (session) session->FlushData ();
|
if (session) session->FlushData ();
|
||||||
|
@ -231,10 +233,17 @@ namespace transport
|
||||||
std::unique_lock<std::mutex> l(m_SessionsMutex);
|
std::unique_lock<std::mutex> l(m_SessionsMutex);
|
||||||
m_Sessions[packet->from] = session;
|
m_Sessions[packet->from] = session;
|
||||||
}
|
}
|
||||||
LogPrint ("New SSU session from ", packet->from.address ().to_string (), ":", packet->from.port (), " created");
|
LogPrint (eLogInfo, "New SSU session from ", packet->from.address ().to_string (), ":", packet->from.port (), " created");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session->ProcessNextMessage (packet->buf, packet->len, packet->from);
|
session->ProcessNextMessage (packet->buf, packet->len, packet->from);
|
||||||
|
}
|
||||||
|
catch (std::exception& ex)
|
||||||
|
{
|
||||||
|
LogPrint (eLogError, "SSU: HandleReceivedPackets ", ex.what ());
|
||||||
|
if (session) session->FlushData ();
|
||||||
|
session = nullptr;
|
||||||
|
}
|
||||||
delete packet;
|
delete packet;
|
||||||
}
|
}
|
||||||
if (session) session->FlushData ();
|
if (session) session->FlushData ();
|
||||||
|
|
Loading…
Add table
Reference in a new issue