From: Mike Pall Date: Thu, 8 Dec 2022 23:20:05 +0000 (+0100) Subject: Correct fix for stack check when recording BC_VARG. X-Git-Tag: v2.1.ROLLING~32^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2791179ef96d652d00d78d2a8780af690537f6a;p=thirdparty%2FLuaJIT.git Correct fix for stack check when recording BC_VARG. Reported by Yichun Zhang. --- diff --git a/src/lj_record.c b/src/lj_record.c index f7552db0..dee53327 100644 --- a/src/lj_record.c +++ b/src/lj_record.c @@ -1522,6 +1522,8 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) } else if (dst + nresults > J->maxslot) { J->maxslot = dst + (BCReg)nresults; } + if (J->baseslot + J->maxslot >= LJ_MAX_JSLOTS) + lj_trace_err(J, LJ_TRERR_STACKOV); for (i = 0; i < nresults; i++) J->base[dst+i] = i < nvararg ? getslot(J, i - nvararg - 1) : TREF_NIL; } else { /* Unknown number of varargs passed to trace. */ @@ -1602,8 +1604,6 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) lj_trace_err_info(J, LJ_TRERR_NYIBC); } } - if (J->baseslot + J->maxslot >= LJ_MAX_JSLOTS) - lj_trace_err(J, LJ_TRERR_STACKOV); } /* -- Record allocations -------------------------------------------------- */