diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2009-12-01 00:31:09 +0100 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2009-12-01 00:31:09 +0100 |
commit | 935d1dbc7dd8357619b2a6892d017c511a7ef57a (patch) | |
tree | 28fef50e82466038d361ecfcd8e5f24f68fdda95 /lib | |
parent | 3699ebd1770218368902469a32daf13ce6057408 (diff) |
Protecting the pushes in order to make sure we have enough stack space every time.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/BLua.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/BLua.cc b/lib/BLua.cc index ba5497a..8f9f59d 100644 --- a/lib/BLua.cc +++ b/lib/BLua.cc @@ -642,12 +642,14 @@ void Lua::open_bit() { } void Lua::declarefunc(const String & name, lua_CFunction f, int i) { + checkstack(2); lua_pushstring(L, name.to_charp()); lua_pushcfunction(L, f); lua_settable(L, i); } void Lua::call(const String & f, int i, int nargs, int nresults) { + checkstack(1); lua_pushstring(L, f.to_charp()); lua_gettable(L, i); lua_insert(L, -1 - nargs - nresults); @@ -657,6 +659,7 @@ void Lua::call(const String & f, int i, int nargs, int nresults) { void Lua::call(int nargs, int nresults) throw(GeneralException) { int r; + checkstack(1); lua_pushcfunction(L, LuaStatics::luaerror); lua_insert(L, 1); _protected = true; @@ -681,6 +684,7 @@ void Lua::call(int nargs, int nresults) throw(GeneralException) { } void Lua::push(const char * s, int size) { + checkstack(); if (size < 0) { lua_pushstring(L, s); } else { @@ -830,6 +834,7 @@ void Lua::load(Handle * h, bool docall) throw (GeneralException) { lf.f = h; + checkstack(); status = lua_load(L, LuaStatics::getF, &lf, h->GetName().to_charp()); if (status) { @@ -895,6 +900,7 @@ void Lua::dumpvars_r(Handle * h, int i, int depth) throw (GeneralException) { depth++; + checkstack(); while(lua_next(L, i) != 0) { if (lua_type(L, -2) == LUA_TSTRING) { if (String(lua_tostring(L, -2)) == String("_G")) { @@ -999,6 +1005,7 @@ void Lua::dumpvars_r(Handle * h, int i, int depth) throw (GeneralException) { } Lua * Lua::thread(bool saveit) { + checkstack(); lua_State * L1 = lua_newthread(L); Lua * Lt = find(L1); if (saveit) { |