From 47df1ca1f8bcec586dd5d13e1b341edb84c4627b Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Tue, 28 Feb 2023 19:24:52 +0100 Subject: [PATCH] !2737 for 0.48 (fixes #7210) --- components/lua/luastate.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/lua/luastate.cpp b/components/lua/luastate.cpp index 0d106cb119..76c574a334 100644 --- a/components/lua/luastate.cpp +++ b/components/lua/luastate.cpp @@ -5,6 +5,7 @@ #endif // NO_LUAJIT #include +#include #include #include @@ -273,7 +274,9 @@ namespace LuaUtil sol::function LuaState::loadInternalLib(std::string_view libName) { std::string path = packageNameToPath(libName, mLibSearchPaths); - sol::load_result res = mLua.load_file(path, sol::load_mode::text); + std::ifstream stream(path); + std::string fileContent(std::istreambuf_iterator(stream), {}); + sol::load_result res = mLua.load(fileContent, path, sol::load_mode::text); if (!res.valid()) throw std::runtime_error("Lua error: " + res.get()); return res;