Skip to content

Commit

Permalink
Merge branch 'theluareloaded' into 'master'
Browse files Browse the repository at this point in the history
Check the result of loading from bytecode

Closes #7787

See merge request OpenMW/openmw!4189
  • Loading branch information
psi29a committed Jun 25, 2024
2 parents 64dd6e3 + 83e8729 commit 9a864f3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/lua/luastate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,14 @@ namespace LuaUtil
{
auto iter = mCompiledScripts.find(path);
if (iter != mCompiledScripts.end())
return mSol.load(iter->second.as_string_view(), path, sol::load_mode::binary);
{
sol::load_result res = mSol.load(iter->second.as_string_view(), path, sol::load_mode::binary);
// Unless we have memory corruption issues, the bytecode is valid at this point, but loading might still
// fail because we've hit our Lua memory cap
if (!res.valid())
throw std::runtime_error("Lua error: " + res.get<std::string>());
return res;
}
sol::function res = loadFromVFS(path);
mCompiledScripts[path] = res.dump();
return res;
Expand Down

0 comments on commit 9a864f3

Please sign in to comment.