shithub: scc

Download patch

ref: 7b77d09eb9716ebb472547635cf8b2dba0908103
parent: ffe766e4bd6d01ff1a8498e63cffca21ca50eab9
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Apr 24 11:30:03 EDT 2014

Fix symbol deletion

When we free a symbol it is the head of the list, so the head is
no longer valid, and it is needed update the head to the next
element in the list.

--- a/symbol.c
+++ b/symbol.c
@@ -31,13 +31,14 @@
 freesyms(uint8_t ns)
 {
 	static struct symtab *tbl;
-	register Symbol *sym;
+	register Symbol *sym, *next;
 
 	tbl = &symtab[(ns >= NR_NAMESPACES) ? NS_IDEN : ns];
-	for (sym = tbl->head; sym; sym = sym->next) {
+	for (sym = tbl->head; sym; sym = next) {
 		if (sym->ctx <= curctx)
 			break;
 		tbl->htab[hash(sym->name)] = sym->hash;
+		next = tbl->head = sym->next;
 		free(sym->name);
 		free(sym);
 	}