[nasm:master] preproc: don't unmacro if macro cannot be found.
nasm-bot for Marco Vanotti
mvanotti at dc.uba.ar
Mon Nov 7 17:12:43 PST 2022
Commit-ID: 6224dd0b45792bbd4dce57be150a463a4ab1d71e
Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=6224dd0b45792bbd4dce57be150a463a4ab1d71e
Author: Marco Vanotti <mvanotti at dc.uba.ar>
AuthorDate: Wed, 2 Jun 2021 13:49:06 -0700
Committer: H. Peter Anvin <hpa at zytor.com>
CommitDate: Mon, 7 Nov 2022 16:30:49 -0800
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
```
[hpa: adjusted code to match NASM style]
Fixes bug 3392761
Signed-off-by: H. Peter Anvin <hpa at zytor.com>
---
asm/preproc.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/asm/preproc.c b/asm/preproc.c
index 058c0325..f3e4511f 100644
--- a/asm/preproc.c
+++ b/asm/preproc.c
@@ -4337,6 +4337,11 @@ issue_error:
goto done;
}
mmac_p = (MMacro **) hash_findi(&mmacros, spec.name, NULL);
+ if (!mmac_p) {
+ /* No such macro */
+ free_tlist(spec.dlist);
+ break;
+ }
/* Check the macro to be undefined is not being expanded */
list_for_each(l, istk->expansion) {
More information about the Nasm-commits
mailing list