Var: add missing references to init in add{,_and_assign}_local()

The reference to `init` is consumed by make_var() and again by the
AssignExpr constructor.
This commit is contained in:
Max Kellermann 2020-02-24 12:54:10 +01:00
parent 2db1c88e4d
commit d49e709bfd

View file

@ -235,6 +235,8 @@ void add_global(ID* id, BroType* t, init_class c, Expr* init,
Stmt* add_local(ID* id, BroType* t, init_class c, Expr* init,
attr_list* attr, decl_type dt)
{
if (init)
Ref(init);
make_var(id, t, c, init, attr, dt, 0);
if ( init )
@ -262,6 +264,7 @@ Stmt* add_local(ID* id, BroType* t, init_class c, Expr* init,
extern Expr* add_and_assign_local(ID* id, Expr* init, Val* val)
{
Ref(init);
make_var(id, 0, INIT_FULL, init, 0, VAR_REGULAR, 0);
Ref(id);
return new AssignExpr(new NameExpr(id), init, 0, val);