summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaState.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Bindings/LuaState.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index ca0a258d9..947e337fc 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -1454,8 +1454,12 @@ bool cLuaState::CallFunction(int a_NumResults)
LOGWARNING("Error in %s calling function %s()", m_SubsystemName.c_str(), CurrentFunctionName.c_str());
// Remove the error handler and error message from the stack:
- ASSERT(lua_gettop(m_LuaState) == 2);
- lua_pop(m_LuaState, 2);
+ auto top = lua_gettop(m_LuaState);
+ if (top < 2)
+ {
+ LogStackValues(Printf("The Lua stack is in an unexpected state, expected at least two values there, but got %d", top).c_str());
+ }
+ lua_pop(m_LuaState, std::min(2, top));
return false;
}