mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-12-21 09:19:31 +08:00
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>
This commit is contained in:
parent
d4607846a4
commit
7eb18213b7
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user