#18 %+n or %-n with n=0 or n>num_params

closed-accepted
1
2008-07-16
2002-05-25
Anonymous
No

In preproc.c, %-n and %+n should probably be handled
like this:

case '-':
n = atoi(t->text+2)-1;
if (n >= mac->nparam)
tt = NULL;
else {
if (n == -1)
tt = NULL;
else {
if (mac->nparam > 1)
n = (n + mac->rotate) % mac->nparam;
tt = mac->params[n];
}
}
if (tt) {
cc = find_cc (tt);
if (cc == -1) {
error (ERR_NONFATAL, "macro parameter %d is
not a condition code", n+1);
text = NULL;
} else {
type = TOK_ID;
if (inverse_ccs[cc] == -1) {
error (ERR_NONFATAL, "condition code `%s'
is not invertible", conditions[cc]);
text = NULL;
} else
text =
nasm_strdup(conditions[inverse_ccs[cc]]);
}
} else {
text = NULL;
}
break;
case '+':
n = atoi(t->text+2)-1;
if (n >= mac->nparam)
tt = NULL;
else {
if (n == -1)
tt = NULL;
else {
if (mac->nparam > 1)
n = (n + mac->rotate) % mac->nparam;
tt = mac->params[n];
}
}
if (tt) {
cc = find_cc (tt);
if (cc == -1) {
error (ERR_NONFATAL, "macro parameter %d is
not a condition code", n+1);
text = NULL;
} else {
type = TOK_ID;
text = nasm_strdup(conditions[cc]);
}
} else {
text = NULL;
}
break;

; eof

Discussion

    • labels: --> Preprocessor Bugs
    • assigned_to: nobody --> unv
     
    • priority: 5 --> 1
    • status: open --> open-works-for-me
     
    • status: open-works-for-me --> closed-accepted