From c8b89a46d9197237db6dec594000ef46e9c99ff3 Mon Sep 17 00:00:00 2001 From: Yuki Tamura Date: Wed, 18 Apr 2012 17:34:46 +0300 Subject: [PATCH] Fix possible Lua stack corruption issue luaD_checkstack could damage the stack, possibly making further references to 'func' invalid. Fix this by using the information inside the CallInfo structure instead of 'func'. --- src/lua/ldo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua/ldo.c b/src/lua/ldo.c index f95d0c657..6fcda0222 100644 --- a/src/lua/ldo.c +++ b/src/lua/ldo.c @@ -330,10 +330,10 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { if (L->hookmask & LUA_MASKCALL) luaD_callhook(L, LUA_HOOKCALL, -1); lua_unlock(L); - if (ttisfunction(func)) + if (ttisfunction(ci->func)) n = (*curr_func(L)->c.f)(L); /* do the actual call */ else - n = ((lua_CFunction)fvalue(func))(L); /* do the actual call */ + n = ((lua_CFunction)fvalue(ci->func))(L); /* do the actual call */ lua_lock(L); if (n < 0) /* yielding? */ return PCRYIELD;