[qfcc] Catch erroneous negative builtin numbers

Setting a builtin number negative makes it a non-builtin function, but
possibly in the middle of another function. Not good.
This commit is contained in:
Bill Currie 2020-03-02 13:32:58 +09:00
parent 0db617719e
commit 5893bd7501
1 changed files with 4 additions and 0 deletions

View File

@ -656,6 +656,10 @@ build_builtin_function (symbol_t *sym, expr_t *bi_val, int far)
bi = expr_integer (bi_val); bi = expr_integer (bi_val);
else else
bi = expr_float (bi_val); bi = expr_float (bi_val);
if (bi < 0) {
error (bi_val, "builtin functions must be positive or 0");
return 0;
}
sym->s.func->builtin = bi; sym->s.func->builtin = bi;
reloc_def_func (sym->s.func, sym->s.func->def); reloc_def_func (sym->s.func, sym->s.func->def);
build_function (sym); build_function (sym);