From f6274e6156e7f520b20b8903bdf33f5b949b75ed Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 1 Dec 2024 15:32:19 -0500 Subject: [PATCH] Fix a LUA stack leak with a missing init fn in wtse (#7889) Oops! If I get a nil I still need to pop it. --- src/common/LuaSupport.cpp | 4 ++++ src/common/dsp/WavetableScriptEvaluator.cpp | 1 + 2 files changed, 5 insertions(+) diff --git a/src/common/LuaSupport.cpp b/src/common/LuaSupport.cpp index 57bfc929cbe..07f243f4e03 100644 --- a/src/common/LuaSupport.cpp +++ b/src/common/LuaSupport.cpp @@ -315,6 +315,10 @@ Surge::LuaSupport::SGLD::~SGLD() { std::cout << "Guarded stack leak: [" << label << "] exit=" << nt << " enter=" << top << std::endl; + for (int i = nt; i >= top; i--) + { + std::cout << " " << i << " -> " << lua_typename(L, lua_type(L, i)) << std::endl; + } } #endif } diff --git a/src/common/dsp/WavetableScriptEvaluator.cpp b/src/common/dsp/WavetableScriptEvaluator.cpp index 0764d04a584..ca6dd8d2492 100644 --- a/src/common/dsp/WavetableScriptEvaluator.cpp +++ b/src/common/dsp/WavetableScriptEvaluator.cpp @@ -75,6 +75,7 @@ struct LuaWTEvaluator::Details lua_getglobal(L, "init"); if (!lua_isfunction(L, -1)) { + lua_pop(L, -1); makeEmptyState(true); } else