Skip to content

Commit

Permalink
fixed memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Jul 7, 2014
1 parent 226ef77 commit e0291bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion NTCPSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ namespace ntcp
m_Socket (service), m_TerminationTimer (service), m_IsEstablished (false),
m_RemoteRouterInfo (in_RemoteRouterInfo), m_ReceiveBufferOffset (0), m_NextMessage (nullptr)
{
m_DHKeysPair = i2p::transports.GetNextDHKeysPair ();
m_DHKeysPair = i2p::transports.GetNextDHKeysPair ();
}

NTCPSession::~NTCPSession ()
{
delete m_DHKeysPair;
delete m_NextMessage;
}

void NTCPSession::CreateAESKey (uint8_t * pubKey, uint8_t * aesKey)
Expand Down
2 changes: 2 additions & 0 deletions Transports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace i2p
{
i2p::data::DHKeysPair * pair = new i2p::data::DHKeysPair ();
i2p::data::CreateRandomDHKeysPair (pair);
std::unique_lock<std::mutex> l(m_AcquiredMutex);
m_Queue.push (pair);
}
}
Expand All @@ -61,6 +62,7 @@ namespace i2p
{
if (!m_Queue.empty ())
{
std::unique_lock<std::mutex> l(m_AcquiredMutex);
auto pair = m_Queue.front ();
m_Queue.pop ();
m_Acquired.notify_one ();
Expand Down

0 comments on commit e0291bb

Please sign in to comment.