fix(lua): memory leak when re-loading Lua scripts (#6372)

This commit is contained in:
philmoz
2025-06-20 08:40:45 +10:00
committed by GitHub
parent 9c27736500
commit a3b59e0ac1
+7
View File
@@ -1377,6 +1377,13 @@ void luaInit()
if (luaState != INTERPRETER_PANIC) {
if (mainState) {
if (lsScripts) {
for (int i = 0; i < luaScriptsCount; i += 1)
luaFree(lsScripts, scriptInternalData[i]);
lua_settop(lsScripts, 0);
lua_gc(lsScripts, LUA_GCCOLLECT, 0);
lsScripts = nullptr;
}
lua_settop(mainState, 0);
lua_gc(mainState, LUA_GCCOLLECT, 0);