Skip to content

Commit 8030f9e

Browse files
committed
fix: crash if lua mod requests unreg hook that is also hooked by another
1 parent abd1a1d commit 8030f9e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

UE4SS/src/Mod/LuaMod.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,12 @@ namespace RC
122122

123123
static auto lua_unreal_script_function_hook_pre(Unreal::UnrealScriptFunctionCallableContext context, void* custom_data) -> void
124124
{
125-
126125
// Fetch the data corresponding to this UFunction
127126
auto& lua_data = *static_cast<LuaUnrealScriptFunctionData*>(custom_data);
128127

128+
// Check if this hook has been scheduled for removal (Lua state may be invalid)
129+
if (lua_data.scheduled_for_removal) return;
130+
129131
// This is a promise that we're in the game thread, used by other functions to ensure that we don't execute when unsafe
130132
set_is_in_game_thread(lua_data.lua, true);
131133

@@ -239,6 +241,9 @@ namespace RC
239241
// Fetch the data corresponding to this UFunction
240242
auto& lua_data = *static_cast<LuaUnrealScriptFunctionData*>(custom_data);
241243

244+
// Check if this hook has been scheduled for removal (Lua state may be invalid)
245+
if (lua_data.scheduled_for_removal) return;
246+
242247
// This is a promise that we're in the game thread, used by other functions to ensure that we don't execute when unsafe
243248
set_is_in_game_thread(lua_data.lua, true);
244249

deps/first/Unreal

0 commit comments

Comments
 (0)