From cac075a1221f373053196dbb24bdcff4609b8241 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 23 Apr 2020 14:39:34 -0300 Subject: Small issue in 'exprstat' The code should not compute an instruction address before checking that it exists. (Virtually no machine complains of computing an invalid address, as long as the address is not used, but for ISO C that is undefined behavior.) --- lparser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lparser.c b/lparser.c index b0dbb65c..27daa926 100644 --- a/lparser.c +++ b/lparser.c @@ -1822,8 +1822,9 @@ static void exprstat (LexState *ls) { restassign(ls, &v, 1); } else { /* stat -> func */ - Instruction *inst = &getinstruction(fs, &v.v); + Instruction *inst; check_condition(ls, v.v.k == VCALL, "syntax error"); + inst = &getinstruction(fs, &v.v); SETARG_C(*inst, 1); /* call statement uses no results */ } } -- cgit v1.2.3-55-g6feb