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

@ -10,6 +10,7 @@
#include "BroList.h"
#include "TraverseTypes.h"
template <class T> class IntrusivePtr;
class ID;
class BroType;
class ListVal;
@ -89,7 +90,7 @@ extern void push_scope(ID* id, attr_list* attrs);
extern void push_existing_scope(Scope* scope);
// Returns the one popped off; it's not deleted.
extern Scope* pop_scope();
extern IntrusivePtr<Scope> pop_scope();
extern Scope* current_scope();
extern Scope* global_scope();