diff options
author | yzh <yaozihao5606@outlook.com> | 2024-02-13 14:49:00 +0800 |
---|---|---|
committer | yzh <yaozihao5606@outlook.com> | 2024-02-13 14:49:00 +0800 |
commit | 4e331c54048ba8dfbc2bc05d85fcc9b517f5fea7 (patch) | |
tree | e2727aa92c6cb443f0e4472eff6d90c3b85bc377 /source/game/scripting | |
parent | 33db825d0424ef6b6061f0ee4f20bb5f8642a389 (diff) |
fix memory leak
Diffstat (limited to 'source/game/scripting')
-rw-r--r-- | source/game/scripting/StarLuaRoot.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
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<String> const& name, Maybe<LuaValue> const& env) -> LuaFunction { + newContext.set("loadstring", m_luaEngine->createFunction([&newContext](String const& source, Maybe<String> const& name, Maybe<LuaValue> const& env) -> LuaFunction { String functionName = name ? strf("loadstring: {}", *name) : "loadstring"; return newContext.engine().createFunctionFromSource(newContext.handleIndex(), source.utf8Ptr(), source.utf8Size(), functionName.utf8Ptr()); })); |