Skip to content

Commit

Permalink
Fix possible Lua stack corruption issue
Browse files Browse the repository at this point in the history
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'.
  • Loading branch information
Yuki Tamura authored and bogdanm committed Apr 18, 2012
1 parent fbebb29 commit c8b89a4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lua/ldo.c
Expand Up @@ -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;
Expand Down

0 comments on commit c8b89a4

Please sign in to comment.