From b280c62ea5eb58f7a437ccb1cdb5ab23757185ad Mon Sep 17 00:00:00 2001 From: Zeke Medley Date: Fri, 21 Jun 2019 12:31:10 -0700 Subject: [PATCH] ClosureFrame takes ownership of its captured vals. --- src/Frame.cc | 6 ++++-- src/Func.cc | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Frame.cc b/src/Frame.cc index 6da6a24584..de110210dd 100644 --- a/src/Frame.cc +++ b/src/Frame.cc @@ -41,11 +41,13 @@ Frame::Frame(const Frame* other) this->break_on_return = false; this->delayed = false; - // We need to Ref this because the - // destructor will Unref. if ( other->trigger ) Ref(other->trigger); + for (int i = 0; i < size; i++) + if (frame[i]) + Ref(frame[i]); + this->trigger = other->trigger; this->call = other->call; } diff --git a/src/Func.cc b/src/Func.cc index b98116c050..57bc8a6b04 100644 --- a/src/Func.cc +++ b/src/Func.cc @@ -317,7 +317,6 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const return Flavor() == FUNC_FLAVOR_HOOK ? val_mgr->GetTrue() : 0; } - // f will hold the closure & function's values Frame* f = new Frame(frame_size, this, args); if (this->closure) {