From 4e331c54048ba8dfbc2bc05d85fcc9b517f5fea7 Mon Sep 17 00:00:00 2001 From: yzh Date: Tue, 13 Feb 2024 14:49:00 +0800 Subject: fix memory leak --- source/game/scripting/StarLuaRoot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/game/scripting/StarLuaRoot.cpp') diff --git a/source/game/scripting/StarLuaRoot.cpp b/source/game/scripting/StarLuaRoot.cpp index c538df1..fc205c0 100644 --- a/source/game/scripting/StarLuaRoot.cpp +++ b/source/game/scripting/StarLuaRoot.cpp @@ -106,7 +106,7 @@ LuaContext LuaRoot::createContext(StringList const& scriptPaths) { } }); - newContext.set("loadstring", m_luaEngine->createFunction([newContext](String const& source, Maybe const& name, Maybe const& env) -> LuaFunction { + newContext.set("loadstring", m_luaEngine->createFunction([&newContext](String const& source, Maybe const& name, Maybe const& env) -> LuaFunction { String functionName = name ? strf("loadstring: {}", *name) : "loadstring"; return newContext.engine().createFunctionFromSource(newContext.handleIndex(), source.utf8Ptr(), source.utf8Size(), functionName.utf8Ptr()); })); -- cgit v1.2.3