diff options
author | Gerald Combs <gerald@wireshark.org> | 2008-12-31 01:20:20 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2008-12-31 01:20:20 +0000 |
commit | 80e2a01faeba2b17b58d51d14296f9c6bde59c69 (patch) | |
tree | 6d33edeebd0a46997631f3a46b8672c4e891235d /epan/wslua/wslua.h | |
parent | bc740b78223ffb8328ec555c112291c52b55a98b (diff) |
From Matt Briggs via bug 3062: Keep Lua from doing rude things to
the stack.
svn path=/trunk/; revision=27139
Diffstat (limited to 'epan/wslua/wslua.h')
-rw-r--r-- | epan/wslua/wslua.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/epan/wslua/wslua.h b/epan/wslua/wslua.h index 7403d03c06..908e314172 100644 --- a/epan/wslua/wslua.h +++ b/epan/wslua/wslua.h @@ -235,7 +235,6 @@ typedef tvbparse_action_t* Shortcut; typedef struct _wslua_main* WireShark; typedef struct _wslua_dir* Dir; - /* * toXxx(L,idx) gets a Xxx from an index (Lua Error if fails) * checkXxx(L,idx) gets a Xxx from an index after calling check_code (No Lua Error if it fails) @@ -259,7 +258,9 @@ C check##C(lua_State* L, int index) { \ return p ? *p : NULL; \ } \ C* push##C(lua_State* L, C v) { \ - C* p = lua_newuserdata(L,sizeof(C)); *p = v; \ + C* p; \ + luaL_checkstack(L,2,"Unable to grow stack\n"); \ + p = lua_newuserdata(L,sizeof(C)); *p = v; \ luaL_getmetatable(L, #C); lua_setmetatable(L, -2); \ push_code; \ return p; \ @@ -297,10 +298,14 @@ typedef int dummy##C lua_pushliteral(L, "__metatable"); \ lua_pushvalue(L, -3); \ lua_rawset(L, -3); \ - lua_pop(L, 1); \ + lua_pop(L, 2); \ } -#define WSLUA_REGISTER_META(C) luaL_newmetatable (L, #C); luaL_register (L, NULL, C ## _meta); +#define WSLUA_REGISTER_META(C) { \ + luaL_newmetatable (L, #C); \ + luaL_register (L, NULL, C ## _meta); \ + lua_pop(L,1); \ +} #define WSLUA_INIT(L) \ luaL_openlibs(L); \ |