From 6bbfb06704812d02fe22cecbc3745ee4b3909c08 Mon Sep 17 00:00:00 2001 From: batrick Date: Tue, 11 Aug 2009 05:56:10 +0000 Subject: [PATCH] Check the stack size before moving elements to the thread. Some threads have truncated stacks after finishing with an error causing a Lua assertion failure when we put elements on the stack without first checking whether space is available. --- nse_nmaplib.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nse_nmaplib.cc b/nse_nmaplib.cc index 4e9c1ff35..d57d6d0be 100644 --- a/nse_nmaplib.cc +++ b/nse_nmaplib.cc @@ -261,6 +261,7 @@ static int aux_mutex (lua_State *L) lua_State *thread = lua_tothread(L, lua_upvalueindex(2)); lua_pushvalue(L, lua_upvalueindex(3)); // destructor key lua_pushvalue(L, lua_upvalueindex(4)); // destructor + luaL_checkstack(thread, 2, "adding destructor"); lua_xmove(L, thread, 2); nse_destructor(thread, 'a'); nse_restore(thread, 0); @@ -295,6 +296,7 @@ static int aux_mutex_done (lua_State *L) lua_State *thread = lua_tothread(L, 1); lua_pushvalue(L, lua_upvalueindex(1)); // aux_mutex, actual mutex closure lua_pushliteral(L, "done"); + luaL_checkstack(thread, 2, "aux_mutex_done"); lua_xmove(L, thread, 2); if (lua_pcall(thread, 1, 0, 0) != 0) lua_pop(thread, 1); // pop error msg return 0;