mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Fix various potential memory leaks.
Though I expect most not to be exercised in practice.
This commit is contained in:
parent
c3a4454892
commit
0b97343ff7
29 changed files with 142 additions and 32 deletions
|
@ -188,5 +188,11 @@ CardinalityCounter* CardinalityCounter::Unserialize(UnserialInfo* info)
|
|||
buckets[i] = (uint8)c;
|
||||
}
|
||||
|
||||
return valid ? c : 0;
|
||||
if ( ! valid )
|
||||
{
|
||||
delete c;
|
||||
c = 0;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
|
|
@ -161,6 +161,7 @@ void TopkVal::Merge(const TopkVal* value, bool doPrune)
|
|||
Element* e = b->elements.front();
|
||||
HashKey* key = GetHash(e->value);
|
||||
elementDict->RemoveEntry(key);
|
||||
delete key;
|
||||
delete e;
|
||||
|
||||
b->elements.pop_front();
|
||||
|
@ -323,6 +324,7 @@ uint64_t TopkVal::GetCount(Val* value) const
|
|||
{
|
||||
HashKey* key = GetHash(value);
|
||||
Element* e = (Element*) elementDict->Lookup(key);
|
||||
delete key;
|
||||
|
||||
if ( e == 0 )
|
||||
{
|
||||
|
@ -330,7 +332,6 @@ uint64_t TopkVal::GetCount(Val* value) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
delete key;
|
||||
return e->parent->count;
|
||||
}
|
||||
|
||||
|
@ -338,6 +339,7 @@ uint64_t TopkVal::GetEpsilon(Val* value) const
|
|||
{
|
||||
HashKey* key = GetHash(value);
|
||||
Element* e = (Element*) elementDict->Lookup(key);
|
||||
delete key;
|
||||
|
||||
if ( e == 0 )
|
||||
{
|
||||
|
@ -345,7 +347,6 @@ uint64_t TopkVal::GetEpsilon(Val* value) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
delete key;
|
||||
return e->epsilon;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue