Skip to content

Commit ae0d289

Browse files
author
H. Peter Anvin
committed
preproc: avoid crashing on %exitmacro in broken nesting
Broken %if, %rep and %macro nesting can result in the %exitmacro unwind overrunning the condition stack. Fix. Fixes: https://bugzilla.nasm.us/show_bug.cgi?id=3392796 Signed-off-by: H. Peter Anvin <[email protected]>
1 parent 65d1eca commit ae0d289

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

asm/preproc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4570,6 +4570,10 @@ static int do_directive(Token *tline, Token **output)
45704570
*/
45714571
for ( ; l->finishes->condcnt > 0; l->finishes->condcnt --) {
45724572
cond = istk->conds;
4573+
if (!cond) {
4574+
l->finishes->condcnt = 0;
4575+
break; /* Possible in case of invalid nesting */
4576+
}
45734577
istk->conds = cond->next;
45744578
nasm_free(cond);
45754579
}

0 commit comments

Comments
 (0)