From aa19f4fd042c7085d1b7f6d692ffee7bf5a7ff80 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 4 Feb 2014 09:18:32 +0100 Subject: Improved error resistance in cPluginManager:CallPlugin(). Fixed: If the call failed, all the next plugin calls would fail as well. --- src/Bindings/LuaState.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index d49cd8ef3..6a02197e8 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -1066,6 +1066,8 @@ int cLuaState::CallFunctionWithForeignParams( { // Something went wrong, fix the stack and exit lua_pop(m_LuaState, 2); + m_NumCurrentFunctionArgs = -1; + m_CurrentFunctionName.clear(); return -1; } @@ -1081,11 +1083,17 @@ int cLuaState::CallFunctionWithForeignParams( { lua_pop(m_LuaState, CurTop - OldTop); } + + // Reset the internal checking mechanisms: + m_NumCurrentFunctionArgs = -1; + m_CurrentFunctionName.clear(); + return -1; } // Reset the internal checking mechanisms: m_NumCurrentFunctionArgs = -1; + m_CurrentFunctionName.clear(); // Remove the error handler from the stack: lua_remove(m_LuaState, OldTop + 1); -- cgit v1.2.3