preproc.c: fix the loop in %undef

The parent-pointer-based freeing loop in %undef should not advance the
parent pointer when a node is freed, since that will result accessing
freed memory.
This commit is contained in:
H. Peter Anvin 2007-09-24 21:33:17 -07:00
parent 82f9f63378
commit e373efdab5

View File

@ -2438,13 +2438,15 @@ static int do_directive(Token * tline)
/*
* We now have a macro name... go hunt for it.
*/
for (sp = smhead; *sp; sp = &(*sp)->next) {
s = *sp;
sp = smhead;
while ((s = *sp) != NULL) {
if (!mstrcmp(s->name, tline->text, s->casesense)) {
*sp = s->next;
nasm_free(s->name);
free_tlist(s->expansion);
nasm_free(s);
} else {
sp = &s->next;
}
}
free_tlist(origline);