From 1c70d2956f969d4c32bf3b2cc3112e0fd98d4162 Mon Sep 17 00:00:00 2001 From: maelstrom Date: Wed, 7 May 2025 10:15:23 +0200 Subject: [PATCH] fix(lua): calling wait without an argument caused segfault --- core/src/objects/script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/objects/script.cpp b/core/src/objects/script.cpp index 9257f65..c41dc26 100644 --- a/core/src/objects/script.cpp +++ b/core/src/objects/script.cpp @@ -68,9 +68,9 @@ void Script::Stop() { int script_wait(lua_State* L) { ScriptContext* scriptContext = (ScriptContext*)lua_touserdata(L, lua_upvalueindex(1)); float secs = lua_gettop(L) == 0 ? 0.03 : std::max(luaL_checknumber(L, 1), 0.03); + if (lua_gettop(L) > 0) lua_pop(L, 1); // pop secs scriptContext->PushThreadSleep(L, secs); - lua_pop(L, 1); // pop secs // Yield return lua_yield(L, 0);