mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fix memory leaks in lambda capture/frame management
This commit is contained in:
parent
614fade0a4
commit
ab15a98b28
1 changed files with 5 additions and 3 deletions
|
@ -484,6 +484,8 @@ void ScriptFunc::CreateCaptures(Frame* f)
|
||||||
|
|
||||||
// Create a private Frame to hold the values of captured variables,
|
// Create a private Frame to hold the values of captured variables,
|
||||||
// and a mapping from those variables to their offsets in the Frame.
|
// and a mapping from those variables to their offsets in the Frame.
|
||||||
|
delete captures_frame;
|
||||||
|
delete captures_offset_mapping;
|
||||||
captures_frame = new Frame(captures->size(), this, nullptr);
|
captures_frame = new Frame(captures->size(), this, nullptr);
|
||||||
captures_offset_mapping = new OffsetMap;
|
captures_offset_mapping = new OffsetMap;
|
||||||
|
|
||||||
|
@ -497,10 +499,8 @@ void ScriptFunc::CreateCaptures(Frame* f)
|
||||||
{
|
{
|
||||||
if ( c->deep_copy || ! v->Modifiable() )
|
if ( c->deep_copy || ! v->Modifiable() )
|
||||||
v = v->Clone();
|
v = v->Clone();
|
||||||
else
|
|
||||||
v->Ref();
|
|
||||||
|
|
||||||
captures_frame->SetElement(offset, v);
|
captures_frame->SetElement(offset, std::move(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
(*captures_offset_mapping)[cid->Name()] = offset;
|
(*captures_offset_mapping)[cid->Name()] = offset;
|
||||||
|
@ -513,6 +513,8 @@ void ScriptFunc::SetCaptures(Frame* f)
|
||||||
auto captures = type->GetCaptures();
|
auto captures = type->GetCaptures();
|
||||||
ASSERT(captures);
|
ASSERT(captures);
|
||||||
|
|
||||||
|
delete captures_frame;
|
||||||
|
delete captures_offset_mapping;
|
||||||
captures_frame = f;
|
captures_frame = f;
|
||||||
captures_offset_mapping = new OffsetMap;
|
captures_offset_mapping = new OffsetMap;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue