commit bc267b974204cd6ddf6f717a0a2597dc33f68406
parent 9bcd185b56a4b5cd1658bd2456ed0d93ef15db4a
Author: Quentin Rameau <quinq@fifth.space>
Date: Thu, 27 Oct 2016 14:17:40 +0200
[cc2] fix symbol hashing of TMPSYM
As TMPSYM is a dummy id, we would always use the same hash for temporary
symbols ending up in a segfault or infinite loop.
Thanks to k0ga for finding a better fix than mine.
Diffstat:
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/cc2/symbol.c b/cc2/symbol.c
@@ -38,7 +38,8 @@ popctx(void)
infunction = 0;
for (sym = locals; sym; sym = next) {
next = sym->next;
- symtab[sym->id & NR_SYMHASH-1] = sym->h_next;
+ if (sym->id != TMPSYM)
+ symtab[sym->id & NR_SYMHASH-1] = sym->h_next;
freesym(sym);
}
curlocal = locals = NULL;
@@ -70,8 +71,10 @@ getsym(unsigned id)
curlocal->next = sym;
curlocal = sym;
}
- sym->h_next = *htab;
- *htab = sym;
+ if (id != TMPSYM) {
+ sym->h_next = *htab;
+ *htab = sym;
+ }
}
return sym;
}