Skip to content

Commit

Permalink
Fix CTD on debugmsg with no Lua instance
Browse files Browse the repository at this point in the history
  • Loading branch information
olanti-p authored Sep 20, 2023
1 parent 7a551f0 commit 9af8a92
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/catalua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,13 @@ void reload_lua_code()

void debug_write_lua_backtrace( std::ostream &out )
{
cata::lua_state &state = *DynamicDataLoader::get_instance().lua;
cata::lua_state *state = DynamicDataLoader::get_instance().lua.get();
if( !state ) {
return;
}
sol::state container;

luaL_traceback( container.lua_state(), state.lua.lua_state(), "=== Lua backtrace report ===", 0 );
luaL_traceback( container.lua_state(), state->lua.lua_state(), "=== Lua backtrace report ===", 0 );

std::string data = sol::stack::pop<std::string>( container );
out << data << std::endl;
Expand Down

0 comments on commit 9af8a92

Please sign in to comment.