ref: c1b398e087ec3d8063c8358ba4a46b244091a1fa
parent: 696edcee98fb98ebe43890ca432106b6a168d2f7
author: Quentin Rameau <[email protected]>
date: Thu Oct 27 10:17:40 EDT 2016
[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.
--- a/cc2/symbol.c
+++ b/cc2/symbol.c
@@ -38,7 +38,8 @@
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 @@
curlocal->next = sym;
curlocal = sym;
}
- sym->h_next = *htab;
- *htab = sym;
+ if (id != TMPSYM) {
+ sym->h_next = *htab;
+ *htab = sym;
+ }
}
return sym;
}