mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 07:08:19 +00:00
GH-734: Improve handling of lambdas that escape enclosing frame
This commit is contained in:
parent
fd8db24daf
commit
eb826bd337
5 changed files with 62 additions and 0 deletions
14
src/Frame.cc
14
src/Frame.cc
|
@ -128,6 +128,20 @@ const zeek::ValPtr& Frame::GetElementByID(const zeek::detail::ID* id) const
|
|||
|
||||
void Frame::Reset(int startIdx)
|
||||
{
|
||||
if ( functions_with_closure_frame_reference )
|
||||
{
|
||||
for ( auto& func : *functions_with_closure_frame_reference )
|
||||
{
|
||||
// A lambda could be escaping its enclosing Frame at this point so
|
||||
// it needs to claim some ownership (or copy) of the Frame in
|
||||
// order to be of any further use.
|
||||
func->StrengthenClosureReference(this);
|
||||
Unref(func);
|
||||
}
|
||||
|
||||
functions_with_closure_frame_reference.reset();
|
||||
}
|
||||
|
||||
for ( int i = startIdx; i < size; ++i )
|
||||
ClearElement(i);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue