diff --git a/src/framework/luascript/luainterface.cpp b/src/framework/luascript/luainterface.cpp index d77828b8..ce94f1a3 100644 --- a/src/framework/luascript/luainterface.cpp +++ b/src/framework/luascript/luainterface.cpp @@ -974,42 +974,50 @@ void* LuaInterface::popUpvalueUserdata() void LuaInterface::pushNil() { lua_pushnil(L); + checkStack(); } void LuaInterface::pushInteger(int v) { lua_pushinteger(L, v); + checkStack(); } void LuaInterface::pushNumber(double v) { lua_pushnumber(L, v); + checkStack(); } void LuaInterface::pushBoolean(bool v) { lua_pushboolean(L, v); + checkStack(); } void LuaInterface::pushCString(const char* v) { assert(v); lua_pushstring(L, v); + checkStack(); } void LuaInterface::pushString(const std::string& v) { lua_pushlstring(L, v.c_str(), v.length()); + checkStack(); } void LuaInterface::pushLightUserdata(void* p) { lua_pushlightuserdata(L, p); + checkStack(); } void LuaInterface::pushThread() { lua_pushthread(L); + checkStack(); } void LuaInterface::pushObject(const LuaObjectPtr& obj) @@ -1026,6 +1034,7 @@ void LuaInterface::pushObject(const LuaObjectPtr& obj) void LuaInterface::pushCFunction(LuaCFunction func, int n) { lua_pushcclosure(L, func, n); + checkStack(); } void LuaInterface::pushCppFunction(const LuaCppFunction& func) @@ -1047,6 +1056,7 @@ void LuaInterface::pushValue(int index) { assert(hasIndex(index)); lua_pushvalue(L, index); + checkStack(); } bool LuaInterface::isNil(int index) diff --git a/src/framework/luascript/luainterface.h b/src/framework/luascript/luainterface.h index bd416d6b..9ca63c7b 100644 --- a/src/framework/luascript/luainterface.h +++ b/src/framework/luascript/luainterface.h @@ -221,6 +221,7 @@ public: void remove(int index); bool next(int index = -2); + void checkStack() { assert(getTop() <= 20); } void getStackFunction(int level = 0); void getRef(int ref);