aboutsummaryrefslogtreecommitdiff
path: root/lparser.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-04-23 14:39:34 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-04-23 14:39:34 -0300
commitcac075a1221f373053196dbb24bdcff4609b8241 (patch)
treee3633c7457ef091b3da81dec6a8f609b9eb432f5 /lparser.c
parent9e0a8475cdd53af664b807c4f0c4d53088a7faf2 (diff)
downloadlua-cac075a1221f373053196dbb24bdcff4609b8241.tar.gz
lua-cac075a1221f373053196dbb24bdcff4609b8241.tar.bz2
lua-cac075a1221f373053196dbb24bdcff4609b8241.zip
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.)
Diffstat (limited to 'lparser.c')
-rw-r--r--lparser.c3
1 files changed, 2 insertions, 1 deletions
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) {
1822 restassign(ls, &v, 1); 1822 restassign(ls, &v, 1);
1823 } 1823 }
1824 else { /* stat -> func */ 1824 else { /* stat -> func */
1825 Instruction *inst = &getinstruction(fs, &v.v); 1825 Instruction *inst;
1826 check_condition(ls, v.v.k == VCALL, "syntax error"); 1826 check_condition(ls, v.v.k == VCALL, "syntax error");
1827 inst = &getinstruction(fs, &v.v);
1827 SETARG_C(*inst, 1); /* call statement uses no results */ 1828 SETARG_C(*inst, 1); /* call statement uses no results */
1828 } 1829 }
1829} 1830}