mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
Fix memory leaks in expire_func introduced by recent changes
This commit is contained in:
parent
1a7f14dab0
commit
01611177f7
1 changed files with 10 additions and 5 deletions
15
src/Val.cc
15
src/Val.cc
|
@ -2318,23 +2318,28 @@ double TableVal::CallExpireFunc(Val* idx)
|
||||||
{
|
{
|
||||||
if ( ! any_idiom )
|
if ( ! any_idiom )
|
||||||
{
|
{
|
||||||
const val_list* vl0 = idx->AsListVal()->Vals();
|
|
||||||
for ( const auto& v : *idx->AsListVal()->Vals() )
|
for ( const auto& v : *idx->AsListVal()->Vals() )
|
||||||
vl.append(v->Ref());
|
vl.append(v->Ref());
|
||||||
|
|
||||||
|
Unref(idx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ListVal* idx_list = idx->AsListVal();
|
ListVal* idx_list = idx->AsListVal();
|
||||||
// Flatten if only one element
|
// Flatten if only one element
|
||||||
if (idx_list->Length() == 1)
|
if ( idx_list->Length() == 1 )
|
||||||
idx = idx_list->Index(0);
|
{
|
||||||
|
Val* old = idx;
|
||||||
|
idx = idx_list->Index(0)->Ref();
|
||||||
|
Unref(old);
|
||||||
|
}
|
||||||
|
|
||||||
vl.append(idx->Ref());
|
vl.append(idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vl.append(idx->Ref());
|
vl.append(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
Val* result = 0;
|
Val* result = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue