]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Fix JIT slot overflow during up-recursion.
authorMike Pall <mike>
Wed, 28 May 2025 19:13:17 +0000 (21:13 +0200)
committerMike Pall <mike>
Wed, 28 May 2025 19:13:17 +0000 (21:13 +0200)
Reported by Sergey Kaplun. #1358

src/lj_record.c

index d336f642e427288e1f1541d2e52b4f56c597e70e..1d535a229902d5836ec2cea698dd34486a395204 100644 (file)
@@ -749,7 +749,8 @@ void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults)
       lj_trace_err(J, LJ_TRERR_LLEAVE);
     } else if (J->needsnap) {  /* Tailcalled to ff with side-effects. */
       lj_trace_err(J, LJ_TRERR_NYIRETL);  /* No way to insert snapshot here. */
-    } else if (1 + pt->framesize >= LJ_MAX_JSLOTS) {
+    } else if (1 + pt->framesize >= LJ_MAX_JSLOTS ||
+              J->baseslot + J->maxslot >= LJ_MAX_JSLOTS) {
       lj_trace_err(J, LJ_TRERR_STACKOV);
     } else {  /* Return to lower frame. Guard for the target we return to. */
       TRef trpt = lj_ir_kgc(J, obj2gco(pt), IRT_PROTO);