mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-04-12 18:40:23 +08:00
preproc: handle empty expansion in %map
%map(foo) should expand to the empty string, but instead crashed NASM. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
e10b7f902b
commit
8584bce804
@ -7449,7 +7449,6 @@ stdmac_map(const SMacro *s, Token **params, int nparam)
|
||||
if (nparam % mparams) {
|
||||
nasm_nonfatal("%s expected a multiple of %d expansion parameters, got %d\n",
|
||||
s->name, mparams, nparam);
|
||||
nparam -= nparam % mparams;
|
||||
}
|
||||
|
||||
ctx = get_ctx(mname, &ctxname);
|
||||
@ -7460,6 +7459,9 @@ stdmac_map(const SMacro *s, Token **params, int nparam)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (nparam < mparams)
|
||||
return NULL; /* Empty expansion */
|
||||
|
||||
greedify = 0;
|
||||
if (unlikely(mparams > smac->nparam)) {
|
||||
if (smac->params[smac->nparam-1].flags & SPARM_GREEDY)
|
||||
@ -7493,7 +7495,7 @@ stdmac_map(const SMacro *s, Token **params, int nparam)
|
||||
}
|
||||
|
||||
nparam -= mparams;
|
||||
if (!nparam)
|
||||
if (nparam < mparams)
|
||||
break;
|
||||
|
||||
params += mparams;
|
||||
|
Loading…
x
Reference in New Issue
Block a user