check lua stack size to avoid possible overflows

This commit is contained in:
Eduardo Bart 2012-06-06 00:44:05 -03:00
parent 2dde63d2bc
commit 7a529d23be
2 changed files with 11 additions and 0 deletions

View File

@ -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)

View File

@ -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);