From c667fedc1a82f631e6789f25b6cfd896d02fd93d Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 13 Oct 2024 15:37:29 +0300 Subject: [PATCH] Fix error handler staying on lua stack after lua commands being called --- src/lua_consolelib.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 3e70ce008..f2fb03dc6 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -81,6 +81,9 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum) lua_pushstring(gL, buf); } LUA_Call(gL, (int)argc, 0, 1); // argc is 1-based, so this will cover the player we passed too. + + lua_pop(gL, 1); // Pop LUA_GetErrorMessage (lua_pcall doesn't pop it) + return; deny: @@ -143,7 +146,7 @@ void COM_Lua_f(void) if (netgame && !( flags & COM_LOCAL ))/* don't send local commands */ { // Send the command through the network UINT8 argc; - lua_pop(gL, 1); // pop command info table + lua_pop(gL, 2); // pop command info table and LUA_GetErrorMessage if (flags & COM_ADMIN && !server && !IsPlayerAdmin(playernum)) // flag 1: only server/admin can use this command. { @@ -182,6 +185,8 @@ void COM_Lua_f(void) for (i = 1; i < COM_Argc(); i++) lua_pushstring(gL, COM_Argv(i)); LUA_Call(gL, (int)COM_Argc(), 0, 1); // COM_Argc is 1-based, so this will cover the player we passed too. + + lua_pop(gL, 1); // Pop LUA_GetErrorMessage (lua_pcall doesn't pop it) } // Wrapper for COM_AddCommand