mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-08 22:13:48 +01:00
fixed memory leak
This commit is contained in:
parent
9b92641112
commit
34d2ae4500
2 changed files with 18 additions and 6 deletions
|
@ -27,7 +27,9 @@ namespace data
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LeaseSet (const uint8_t * buf, int len);
|
LeaseSet (const uint8_t * buf, int len);
|
||||||
|
LeaseSet (const LeaseSet& ) = default;
|
||||||
|
LeaseSet& operator=(const LeaseSet& ) = default;
|
||||||
|
|
||||||
// implements RoutingDestination
|
// implements RoutingDestination
|
||||||
const Identity& GetIdentity () const { return m_Identity; };
|
const Identity& GetIdentity () const { return m_Identity; };
|
||||||
const IdentHash& GetIdentHash () const { return m_IdentHash; };
|
const IdentHash& GetIdentHash () const { return m_IdentHash; };
|
||||||
|
|
20
NetDb.cpp
20
NetDb.cpp
|
@ -119,10 +119,9 @@ namespace data
|
||||||
if (r->GetTimestamp () > it->second->GetTimestamp ())
|
if (r->GetTimestamp () > it->second->GetTimestamp ())
|
||||||
{
|
{
|
||||||
LogPrint ("RouterInfo updated");
|
LogPrint ("RouterInfo updated");
|
||||||
*m_RouterInfos[r->GetIdentHash ()] = *r; // we can't replace point because it's used by tunnels
|
*(it->second) = *r; // we can't replace pointer because it's used by tunnels
|
||||||
}
|
}
|
||||||
else
|
delete r;
|
||||||
delete r;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -135,7 +134,18 @@ namespace data
|
||||||
{
|
{
|
||||||
LeaseSet * l = new LeaseSet (buf, len);
|
LeaseSet * l = new LeaseSet (buf, len);
|
||||||
DeleteRequestedDestination (l->GetIdentHash ());
|
DeleteRequestedDestination (l->GetIdentHash ());
|
||||||
m_LeaseSets[l->GetIdentHash ()] = l;
|
auto it = m_LeaseSets.find(l->GetIdentHash ());
|
||||||
|
if (it != m_LeaseSets.end ())
|
||||||
|
{
|
||||||
|
LogPrint ("LeaseSet updated");
|
||||||
|
*(it->second) = *l; // we can't replace pointer because it's used by streams
|
||||||
|
delete l;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogPrint ("New LeaseSet added");
|
||||||
|
m_LeaseSets[l->GetIdentHash ()] = l;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RouterInfo * NetDb::FindRouter (const IdentHash& ident) const
|
RouterInfo * NetDb::FindRouter (const IdentHash& ident) const
|
||||||
|
|
Loading…
Add table
Reference in a new issue