From 309fb42b871b6414f53e0e0e708bce0b0d62daff Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 28 Aug 2023 21:00:37 +0200 Subject: Fix predict_next() in parser (again). Reported by Sergey Bronnikov. #1054 --- src/lj_parse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lj_parse.c b/src/lj_parse.c index c0cbd261..afdbcc3d 100644 --- a/src/lj_parse.c +++ b/src/lj_parse.c @@ -2527,9 +2527,11 @@ static void parse_for_num(LexState *ls, GCstr *varname, BCLine line) */ static int predict_next(LexState *ls, FuncState *fs, BCPos pc) { - BCIns ins = fs->bcbase[pc].ins; + BCIns ins; GCstr *name; cTValue *o; + if (pc >= fs->bclim) return 0; + ins = fs->bcbase[pc].ins; switch (bc_op(ins)) { case BC_MOV: if (bc_d(ins) >= fs->nactvar) return 0; -- cgit v1.2.3-55-g6feb