summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2020-06-01 12:04:35 -0700
committerH. Peter Anvin (Intel) <hpa@zytor.com>2020-06-01 12:04:35 -0700
commit7cfd01868cf17ea714938db093dad0845fb086f9 (patch)
tree9c46b299afe745fb44234f08a8bc9a83476e13be
parenta762cd4e5402a3605c4962567c47c36c2bd3accf (diff)
downloadnasm-7cfd01868cf17ea714938db093dad0845fb086f9.tar.gz
BR 3392668: in %define, don't set "definining" until confirmed
Don't set "defining" until the macro definition is successfully parsed and we know for sure that we are going to define the macro. Together with: a762cd4e5402a360 BR 3392668: preproc: test for macro in TOK_LOCAL_SYMBOL ... this addresses BR 3392668. Reported-by: <puppet@zju.edu.cn> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r--asm/preproc.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/asm/preproc.c b/asm/preproc.c
index c7b2e7d4..3873d9bf 100644
--- a/asm/preproc.c
+++ b/asm/preproc.c
@@ -3807,17 +3807,21 @@ issue_error:
case PP_RMACRO:
case PP_MACRO:
+ {
+ MMacro *def;
+
nasm_assert(!defining);
- nasm_new(defining);
- defining->casesense = casesense;
- defining->dstk.mmac = defining;
+ nasm_new(def);
+ def->casesense = casesense;
+ def->dstk.mmac = defining;
if (op == PP_RMACRO)
- defining->max_depth = nasm_limit[LIMIT_MACRO_LEVELS];
- if (!parse_mmacro_spec(tline, defining, dname)) {
- nasm_free(defining);
+ def->max_depth = nasm_limit[LIMIT_MACRO_LEVELS];
+ if (!parse_mmacro_spec(tline, def, dname)) {
+ nasm_free(def);
goto done;
}
+ defining = def;
src_get(&defining->xline, &defining->fname);
mmac = (MMacro *) hash_findix(&mmacros, defining->name);
@@ -3834,6 +3838,7 @@ issue_error:
mmac = mmac->next;
}
break;
+ }
case PP_ENDM:
case PP_ENDMACRO: