From d4c1ab172828045f13279402d2b07ba0cc5c74b4 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 5 Jun 2022 01:59:27 -0700 Subject: [PATCH] Scripting: Fix some Lua memory lifetimes --- src/script/engines/lua.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/script/engines/lua.c b/src/script/engines/lua.c index db1178993..2770e8898 100644 --- a/src/script/engines/lua.c +++ b/src/script/engines/lua.c @@ -106,6 +106,7 @@ static const luaL_Reg _mSTTable[] = { { "__index", _luaGetTable }, { "__len", _luaLenTable }, { "__pairs", _luaPairsTable }, + { "__gc", _luaGcObject }, { NULL, NULL } }; @@ -412,7 +413,6 @@ bool _luaWrap(struct mScriptEngineContextLua* luaContext, struct mScriptValue* v *newValue = mSCRIPT_MAKE(WEAKREF, weakref); } else { mScriptValueWrap(value, newValue); - mScriptValueDeref(value); } luaL_setmetatable(luaContext->lua, "mSTList"); break; @@ -422,7 +422,6 @@ bool _luaWrap(struct mScriptEngineContextLua* luaContext, struct mScriptValue* v *newValue = mSCRIPT_MAKE(WEAKREF, weakref); } else { mScriptValueWrap(value, newValue); - mScriptValueDeref(value); } luaL_setmetatable(luaContext->lua, "mSTTable"); break; @@ -440,7 +439,6 @@ bool _luaWrap(struct mScriptEngineContextLua* luaContext, struct mScriptValue* v *newValue = mSCRIPT_MAKE(WEAKREF, weakref); } else { mScriptValueWrap(value, newValue); - mScriptValueDeref(value); } luaL_setmetatable(luaContext->lua, "mSTStruct"); break;