From 5893bd750135a95222ae34f004da7c9bc27af31b Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 2 Mar 2020 13:32:58 +0900 Subject: [PATCH] [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. --- tools/qfcc/source/function.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/qfcc/source/function.c b/tools/qfcc/source/function.c index 3b844b5a3..e2b87d04a 100644 --- a/tools/qfcc/source/function.c +++ b/tools/qfcc/source/function.c @@ -656,6 +656,10 @@ build_builtin_function (symbol_t *sym, expr_t *bi_val, int far) bi = expr_integer (bi_val); else 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; reloc_def_func (sym->s.func, sym->s.func->def); build_function (sym);