From ae3ecabceab6e1d95da354d7848fb5dff687c330 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:25:46 +1100 Subject: loadstring shouldn't accept bytecode --- source/game/scripting/StarLuaRoot.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/game/scripting/StarLuaRoot.cpp') diff --git a/source/game/scripting/StarLuaRoot.cpp b/source/game/scripting/StarLuaRoot.cpp index d79e8f4..a14d10a 100644 --- a/source/game/scripting/StarLuaRoot.cpp +++ b/source/game/scripting/StarLuaRoot.cpp @@ -108,9 +108,9 @@ LuaContext LuaRoot::createContext(StringList const& scriptPaths) { auto handleIndex = newContext.handleIndex(); auto engine = m_luaEngine.get(); - newContext.set("loadstring", m_luaEngine->createFunction([engine,handleIndex](String const& source, Maybe const& name, Maybe const& env) -> LuaFunction { + newContext.set("loadstring", m_luaEngine->createFunction([engine, handleIndex](String const& source, Maybe const& name, Maybe const& env) -> LuaFunction { String functionName = name ? strf("loadstring: {}", *name) : "loadstring"; - return engine->createFunctionFromSource(handleIndex, source.utf8Ptr(), source.utf8Size(), functionName.utf8Ptr()); + return engine->createFunctionFromSource(env ? env->handleIndex() : handleIndex, source.utf8Ptr(), source.utf8Size(), functionName.utf8Ptr()); })); auto assets = Root::singleton().assets(); -- cgit v1.2.3