Skip to content

Commit ad87202

Browse files
committed
preproc: don't unmacro if macro cannot be found.
This commit adds a check to see if the macro that we want to unmacro exists. A previous commit, introduced a check to see if the unmacro was undefining a macro being expanded, but that same check included a null pointer dereference if the macro to undefine did not exist. The following code reproduced the issue: ```asm %macro baz 0 %unmacro F 0 %endmacro baz ``` Compile with: ```shell $ nasm -f elf64 -g -FDWARF -o tmp.o -werror file.asm ``` Fixes bug 3392761
1 parent e2ed7b7 commit ad87202

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

asm/preproc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4330,6 +4330,11 @@ static int do_directive(Token *tline, Token **output)
43304330
goto done;
43314331
}
43324332
mmac_p = (MMacro **) hash_findi(&mmacros, spec.name, NULL);
4333+
if (mmac_p == NULL) {
4334+
nasm_nonfatal("`%%unmacro' cannot find the given macro");
4335+
free_tlist(spec.dlist);
4336+
break;
4337+
}
43334338

43344339
/* Check the macro to be undefined is not being expanded */
43354340
list_for_each(l, istk->expansion) {

0 commit comments

Comments
 (0)