Skip to content

Commit

Permalink
[add] safer handling of executing scripts via api
Browse files Browse the repository at this point in the history
  • Loading branch information
begla committed Aug 18, 2024
1 parent e6a25ae commit 4edcd52
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions iolite_plugins/lua_plugin/lua_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,9 +925,12 @@ IO_API_EXPORT int IO_API_CALL load_plugin(void* api_manager)
// Register the interfaces we provide
{
io_plugin_lua.execute_script = [](const char* script) {
sol::state s;
script_init_state(s);
s.script(script);
sol::state state;
script_init_state(state);
auto s = state.load(script);

if (s.valid())
SOL_VALIDATE_RESULT(s(), "Call to 'execute_script'");
};

io_api_manager->register_api(IO_PLUGIN_LUA_API_NAME, &io_plugin_lua);
Expand Down

0 comments on commit 4edcd52

Please sign in to comment.