Scripting: Fix some Lua memory lifetimes

This commit is contained in:
Vicki Pfau 2022-06-05 01:59:27 -07:00
parent d6accc4ef6
commit d4c1ab1728
1 changed files with 1 additions and 3 deletions

View File

@ -106,6 +106,7 @@ static const luaL_Reg _mSTTable[] = {
{ "__index", _luaGetTable }, { "__index", _luaGetTable },
{ "__len", _luaLenTable }, { "__len", _luaLenTable },
{ "__pairs", _luaPairsTable }, { "__pairs", _luaPairsTable },
{ "__gc", _luaGcObject },
{ NULL, NULL } { NULL, NULL }
}; };
@ -412,7 +413,6 @@ bool _luaWrap(struct mScriptEngineContextLua* luaContext, struct mScriptValue* v
*newValue = mSCRIPT_MAKE(WEAKREF, weakref); *newValue = mSCRIPT_MAKE(WEAKREF, weakref);
} else { } else {
mScriptValueWrap(value, newValue); mScriptValueWrap(value, newValue);
mScriptValueDeref(value);
} }
luaL_setmetatable(luaContext->lua, "mSTList"); luaL_setmetatable(luaContext->lua, "mSTList");
break; break;
@ -422,7 +422,6 @@ bool _luaWrap(struct mScriptEngineContextLua* luaContext, struct mScriptValue* v
*newValue = mSCRIPT_MAKE(WEAKREF, weakref); *newValue = mSCRIPT_MAKE(WEAKREF, weakref);
} else { } else {
mScriptValueWrap(value, newValue); mScriptValueWrap(value, newValue);
mScriptValueDeref(value);
} }
luaL_setmetatable(luaContext->lua, "mSTTable"); luaL_setmetatable(luaContext->lua, "mSTTable");
break; break;
@ -440,7 +439,6 @@ bool _luaWrap(struct mScriptEngineContextLua* luaContext, struct mScriptValue* v
*newValue = mSCRIPT_MAKE(WEAKREF, weakref); *newValue = mSCRIPT_MAKE(WEAKREF, weakref);
} else { } else {
mScriptValueWrap(value, newValue); mScriptValueWrap(value, newValue);
mScriptValueDeref(value);
} }
luaL_setmetatable(luaContext->lua, "mSTStruct"); luaL_setmetatable(luaContext->lua, "mSTStruct");
break; break;