From 0e53a314d7910898e1ea5ba90385d43e8a6c5e57 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Sat, 29 May 2021 15:31:13 +0200 Subject: [PATCH] Fix use-def analysis for vararg functions. Reported by Shmuel Zeigerman. --- src/lj_snap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lj_snap.c b/src/lj_snap.c index 0c5e8e90..eb14058e 100644 --- a/src/lj_snap.c +++ b/src/lj_snap.c @@ -271,8 +271,10 @@ static BCReg snap_usedef(jit_State *J, uint8_t *udf, void lj_snap_purge(jit_State *J) { uint8_t udf[SNAP_USEDEF_SLOTS]; - BCReg maxslot = J->maxslot; - BCReg s = snap_usedef(J, udf, J->pc, maxslot); + BCReg s, maxslot = J->maxslot; + if (bc_op(*J->pc) == BC_FUNCV && maxslot > J->pt->numparams) + maxslot = J->pt->numparams; + s = snap_usedef(J, udf, J->pc, maxslot); for (; s < maxslot; s++) if (udf[s] != 0) J->base[s] = 0; /* Purge dead slots. */