Commit 9755dc71 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

vcc: Plug inconsequential leak

The VCC_GlobalSymbol() function might be called twice for the same
symbol. For example a subroutine symbol may be created when the sub
keyword is first encountered, but it was referenced by a call action
before the subroutine definition.

The main problem the leak is causing is lsan's output polluting test
cases looking at the screen output of varnishd, making the lines we
care about scroll out to oblivion. To remedy this, VCC_GlobalSymbol()
idempotence becomes free of side effects.
parent 1af069bc
......@@ -513,12 +513,22 @@ VCC_WalkSymbols(struct vcc *tl, symwalk_f *func, vcc_ns_t ns, vcc_kind_t kind)
void
VCC_GlobalSymbol(struct symbol *sym, vcc_type_t type)
{
vcc_kind_t kind;
struct vsb *vsb;
CHECK_OBJ_NOTNULL(sym, SYMBOL_MAGIC);
AN(type);
AN(type->global_pfx);
kind = VCC_HandleKind(type);
if (sym->lname != NULL) {
AN(sym->rname);
assert(sym->type == type);
assert(sym->kind == kind);
return;
}
vsb = VSB_new_auto();
AN(vsb);
VSB_printf(vsb, "%s_", type->global_pfx);
......@@ -536,7 +546,7 @@ VCC_GlobalSymbol(struct symbol *sym, vcc_type_t type)
VSB_destroy(&vsb);
sym->type = type;
sym->kind = VCC_HandleKind(sym->type);
sym->kind = kind;
if (sym->kind != SYM_NONE) {
AZ(VCT_invalid_name(sym->rname, NULL));
if (type == SUB)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment