diff options
author | H. Peter Anvin (Intel) <hpa@zytor.com> | 2019-08-20 16:24:46 -0700 |
---|---|---|
committer | H. Peter Anvin (Intel) <hpa@zytor.com> | 2019-08-20 16:24:46 -0700 |
commit | 7eb18213b78f06b45c85e2b224613cce4a20304b (patch) | |
tree | 9e1af612e8a3facb7b6c5834fb41d326b86d9901 | |
parent | d4607846a4e0774aa134b15e8ffe8e3a0a18efa0 (diff) | |
download | nasm-7eb18213b78f06b45c85e2b224613cce4a20304b.tar.gz |
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.c | 7 |
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(¶ms[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; |