Browse Source

fixed memory leak

pull/73/merge
orignal 11 years ago
parent
commit
e0291bb815
  1. 3
      NTCPSession.cpp
  2. 2
      Transports.cpp

3
NTCPSession.cpp

@ -23,12 +23,13 @@ namespace ntcp @@ -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)

2
Transports.cpp

@ -52,6 +52,7 @@ namespace i2p @@ -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);
}
}
@ -61,6 +62,7 @@ namespace i2p @@ -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 ();

Loading…
Cancel
Save