From 4bcbfc3473302a85e720cb6b12e654a37e9c7b90 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 11 Sep 2023 00:32:01 +0900 Subject: [PATCH] [qfcc] Fix an uninitialized test When the function is empty, not even a stack adjust instruction is emitted, so checking for one wound up accessing uninitialized memory. --- tools/qfcc/source/function.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qfcc/source/function.c b/tools/qfcc/source/function.c index b02dc30c4..57de54a16 100644 --- a/tools/qfcc/source/function.c +++ b/tools/qfcc/source/function.c @@ -819,7 +819,7 @@ build_code_function (symbol_t *fsym, expr_t *state_expr, expr_t *statements) STACK_ALIGN); dstatement_t *st = &pr.code->code[func->code]; - if (st->op == OP_ADJSTK) { + if (pr.code->size > func->code && st->op == OP_ADJSTK) { if (func->params_start) { st->b = -func->params_start; } else {