aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2019-08-20 16:24:46 -0700
committerH. Peter Anvin (Intel) <hpa@zytor.com>2019-08-20 16:24:46 -0700
commit7eb18213b78f06b45c85e2b224613cce4a20304b (patch)
tree9e1af612e8a3facb7b6c5834fb41d326b86d9901
parentd4607846a4e0774aa134b15e8ffe8e3a0a18efa0 (diff)
downloadnasm-7eb18213b78f06b45c85e2b224613cce4a20304b.tar.gz
nasm-7eb18213b78f06b45c85e2b224613cce4a20304b.tar.xz
nasm-7eb18213b78f06b45c85e2b224613cce4a20304b.zip
preproc: make sure the mmacro params list is NULL-terminated
If we adjust nparams due to default or greedy arguments, we need to re-terminate the params[] array. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r--asm/preproc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/asm/preproc.c b/asm/preproc.c
index a3f8b7de..c8d86656 100644
--- a/asm/preproc.c
+++ b/asm/preproc.c
@@ -5138,7 +5138,6 @@ static MMacro *is_mmacro(Token * tline, int *nparamp, Token ***params_array)
memcpy(&params[nparam+1], &m->defaults[nparam+1-m->nparam_min],
(newnparam - nparam) * sizeof(*params));
nparam = newnparam;
- params[nparam+1] = NULL;
}
/*
* If we've gone over the maximum parameter count (and
@@ -5148,6 +5147,12 @@ static MMacro *is_mmacro(Token * tline, int *nparamp, Token ***params_array)
if (m->plus && nparam > m->nparam_max)
nparam = m->nparam_max;
+ /*
+ * If nparam was adjusted above, make sure the list is still
+ * NULL-terminated.
+ */
+ params[nparam+1] = NULL;
+
/* Done! */
*params_array = params;
*nparamp = nparam;