Skip to content

Commit f969c33

Browse files
committed
fix: use-after-free issue in lua_unreal_script_function_hook_post
1 parent 4f532da commit f969c33

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

UE4SS/src/Mod/LuaMod.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,10 @@ namespace RC
400400
process_return_value();
401401
process_return_value();
402402

403+
// No longer promising to be in the game thread
404+
// Must be done before cleanup since cleanup deletes lua_data
405+
set_is_in_game_thread(lua_data.lua, false);
406+
403407
if (lua_data.scheduled_for_removal)
404408
{
405409
auto native_hook_post_id_it = LuaMod::m_generic_hook_id_to_native_hook_id.find(lua_data.post_callback_id);
@@ -418,9 +422,6 @@ namespace RC
418422
return elem.get() == &lua_data;
419423
});
420424
}
421-
422-
// No longer promising to be in the game thread
423-
set_is_in_game_thread(lua_data.lua, false);
424425
}
425426

426427
static auto register_input_globals(const LuaMadeSimple::Lua& lua) -> void

0 commit comments

Comments
 (0)