diff --git a/client/deps/liblua/ldblib.c b/client/deps/liblua/ldblib.c index aed9708fe..4d1b437bf 100644 --- a/client/deps/liblua/ldblib.c +++ b/client/deps/liblua/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.132 2012/01/19 20:14:44 roberto Exp $ +** $Id: ldblib.c,v 1.132.1.1 2013/04/12 18:48:47 roberto Exp roberto $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -20,6 +20,10 @@ #define HOOKKEY "_HKEY" +static void checkstack (lua_State *L, lua_State *L1, int n) { + if (L != L1 && !lua_checkstack(L1, n)) + luaL_error(L, "stack overflow"); +} static int db_getregistry(lua_State *L) { @@ -112,6 +116,7 @@ static int db_getinfo(lua_State *L) { int arg; lua_State *L1 = getthread(L, &arg); const char *options = luaL_optstring(L, arg + 2, "flnStu"); + checkstack(L, L1, 3); if (lua_isnumber(L, arg + 1)) { if (!lua_getstack(L1, (int)lua_tointeger(L, arg + 1), &ar)) { lua_pushnil(L); /* level out of range */ @@ -168,6 +173,7 @@ static int db_getlocal(lua_State *L) { } else { /* stack-level argument */ if (!lua_getstack(L1, luaL_checkint(L, arg + 1), &ar)) /* out of range? */ return luaL_argerror(L, arg + 1, "level out of range"); + checkstack(L, L1, 1); name = lua_getlocal(L1, &ar, nvar); if (name) { lua_xmove(L1, L, 1); /* push local value */ @@ -190,6 +196,7 @@ static int db_setlocal(lua_State *L) { return luaL_argerror(L, arg + 1, "level out of range"); luaL_checkany(L, arg + 3); lua_settop(L, arg + 3); + checkstack(L, L1, 1); lua_xmove(L, L1, 1); lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg + 2))); return 1; @@ -309,6 +316,7 @@ static int db_sethook(lua_State *L) { lua_pushvalue(L, -1); lua_setmetatable(L, -2); /* setmetatable(hooktable) = hooktable */ } + checkstack(L, L1, 1); lua_pushthread(L1); lua_xmove(L1, L, 1); lua_pushvalue(L, arg + 1); @@ -328,6 +336,7 @@ static int db_gethook(lua_State *L) { lua_pushliteral(L, "external hook"); else { gethooktable(L); + checkstack(L, L1, 1); lua_pushthread(L1); lua_xmove(L1, L, 1); lua_rawget(L, -2); /* get hook */