Scope: pop_scope() returns IntrusivePtr<>

Make sure unused scopes are freed to fix memory leaks.

The comment inside pop_scope() is now obsolete and I deleted it,
because this commit implements the real solution.

Note that this requires us to add a reference to the
push_existing_scope() call in dbg_eval_expr(), because it never owned
the reference.
This commit is contained in:
Max Kellermann 2020-02-26 05:48:38 +01:00
parent 8ea1d89529
commit 875bfc09a2
5 changed files with 13 additions and 9 deletions

View file

@ -20,6 +20,7 @@ using namespace std;
#include "Stmt.h"
#include "Frame.h"
#include "Func.h"
#include "IntrusivePtr.h"
#include "Scope.h"
#include "PolicyFile.h"
#include "Desc.h"
@ -968,7 +969,10 @@ Val* dbg_eval_expr(const char* expr)
const BroFunc* func = frame->GetFunction();
if ( func )
{
Ref(func->GetScope());
push_existing_scope(func->GetScope());
}
// ### Possibly push a debugger-local scope?