From e0291bb815fc9e709f661d01984309b94939d9ab Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 7 Jul 2014 12:34:19 -0400 Subject: [PATCH] fixed memory leak --- NTCPSession.cpp | 3 ++- Transports.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NTCPSession.cpp b/NTCPSession.cpp index 9930dead..14b79c19 100644 --- a/NTCPSession.cpp +++ b/NTCPSession.cpp @@ -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) diff --git a/Transports.cpp b/Transports.cpp index 54562fc7..e86ed66e 100644 --- a/Transports.cpp +++ b/Transports.cpp @@ -52,6 +52,7 @@ namespace i2p { i2p::data::DHKeysPair * pair = new i2p::data::DHKeysPair (); i2p::data::CreateRandomDHKeysPair (pair); + std::unique_lock l(m_AcquiredMutex); m_Queue.push (pair); } } @@ -61,6 +62,7 @@ namespace i2p { if (!m_Queue.empty ()) { + std::unique_lock l(m_AcquiredMutex); auto pair = m_Queue.front (); m_Queue.pop (); m_Acquired.notify_one ();