From: Mike Pall Date: Wed, 8 Dec 2010 18:11:58 +0000 (+0100) Subject: Avoid stack resizes while recording calls to vararg functions. X-Git-Tag: v2.0.0-beta6~158 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0b283e596b3ea7da7438b1a17f4ecfb98e7c97a;p=thirdparty%2FLuaJIT.git Avoid stack resizes while recording calls to vararg functions. FUNCV might have been recorded twice (with ill effects). --- diff --git a/src/lj_dispatch.c b/src/lj_dispatch.c index 80a6ef2f..4eb6033b 100644 --- a/src/lj_dispatch.c +++ b/src/lj_dispatch.c @@ -388,9 +388,12 @@ void LJ_FASTCALL lj_dispatch_ins(lua_State *L, const BCIns *pc) static int call_init(lua_State *L, GCfunc *fn) { if (isluafunc(fn)) { - int numparams = funcproto(fn)->numparams; + GCproto *pt = funcproto(fn); + int numparams = pt->numparams; int gotparams = (int)(L->top - L->base); - lj_state_checkstack(L, (MSize)numparams); + int need = pt->framesize; + if ((pt->flags & PROTO_IS_VARARG)) need += 1+gotparams; + lj_state_checkstack(L, (MSize)need); numparams -= gotparams; return numparams >= 0 ? numparams : 0; } else {