]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Fix predict_next() in parser (again).
authorMike Pall <mike>
Mon, 28 Aug 2023 19:00:37 +0000 (21:00 +0200)
committerMike Pall <mike>
Mon, 28 Aug 2023 19:00:37 +0000 (21:00 +0200)
Reported by Sergey Bronnikov. #1054

src/lj_parse.c

index c0cbd261c98452a191c79dc8dd5ea5845565c477..afdbcc3d5f3cdac2ef3e65abeff81567658a8f1a 100644 (file)
@@ -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;