mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
fixed memory leak
This commit is contained in:
parent
73ef5e29c2
commit
226ef77927
|
@ -1,4 +1,5 @@
|
|||
#include <string.h>
|
||||
#include <atomic>
|
||||
#include "I2PEndian.h"
|
||||
#include <cryptopp/sha.h>
|
||||
#include <cryptopp/gzip.h>
|
||||
|
@ -29,7 +30,7 @@ namespace i2p
|
|||
delete msg;
|
||||
}
|
||||
|
||||
static uint32_t I2NPmsgID = 0; // TODO: create class
|
||||
static std::atomic<uint32_t> I2NPmsgID(0); // TODO: create class
|
||||
void FillI2NPMessageHeader (I2NPMessage * msg, I2NPMessageType msgType, uint32_t replyMsgID)
|
||||
{
|
||||
I2NPHeader * header = msg->GetHeader ();
|
||||
|
|
2
SSU.cpp
2
SSU.cpp
|
@ -626,7 +626,7 @@ namespace ssu
|
|||
if (!m_DelayedMessages.empty ())
|
||||
{
|
||||
for (auto it :m_DelayedMessages)
|
||||
delete it;
|
||||
DeleteI2NPMessage (it);
|
||||
m_DelayedMessages.clear ();
|
||||
}
|
||||
}
|
||||
|
|
12
SSUData.cpp
12
SSUData.cpp
|
@ -98,7 +98,7 @@ namespace ssu
|
|||
}
|
||||
else if (fragmentNum < it->second->nextFragmentNum)
|
||||
// duplicate fragment
|
||||
LogPrint ("Duplicate fragment ", fragmentNum, " of message ", msgID, ". Ignored");
|
||||
LogPrint ("Duplicate fragment ", (int)fragmentNum, " of message ", msgID, ". Ignored");
|
||||
else
|
||||
{
|
||||
// missing fragment
|
||||
|
@ -108,7 +108,7 @@ namespace ssu
|
|||
|
||||
if (isLast)
|
||||
{
|
||||
if (!msg)
|
||||
if (!msg)
|
||||
DeleteI2NPMessage (it->second->msg);
|
||||
delete it->second;
|
||||
m_IncomleteMessages.erase (it);
|
||||
|
@ -116,7 +116,7 @@ namespace ssu
|
|||
}
|
||||
else
|
||||
// TODO:
|
||||
LogPrint ("Unexpected follow-on fragment ", fragmentNum, " of message ", msgID);
|
||||
LogPrint ("Unexpected follow-on fragment ", (int)fragmentNum, " of message ", msgID);
|
||||
}
|
||||
else // first fragment
|
||||
{
|
||||
|
@ -156,6 +156,12 @@ namespace ssu
|
|||
void SSUData::Send (i2p::I2NPMessage * msg)
|
||||
{
|
||||
uint32_t msgID = msg->ToSSU ();
|
||||
if (m_SentMessages.count (msgID) > 0)
|
||||
{
|
||||
LogPrint ("SSU message ", msgID, " already sent");
|
||||
DeleteI2NPMessage (msg);
|
||||
return;
|
||||
}
|
||||
auto fragments = m_SentMessages[msgID];
|
||||
msgID = htobe32 (msgID);
|
||||
size_t payloadSize = SSU_MTU - sizeof (SSUHeader) - 9; // 9 = flag + #frg(1) + messageID(4) + frag info (3)
|
||||
|
|
Loading…
Reference in a new issue