Skip to content

Commit 12c6627

Browse files
committed
fix: Accidentally removed early exit when UnregisterHook is called from within a pre-callback
1 parent c1ae2ee commit 12c6627

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

UE4SS/src/Mod/LuaMod.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ namespace RC
232232
// Fetch the data corresponding to this UFunction
233233
auto& lua_data = *static_cast<LuaUnrealScriptFunctionData*>(custom_data);
234234

235-
auto remove_if_scheduled = [&] {
235+
// Returns true if a hooks were removed.
236+
auto remove_if_scheduled = [&] -> bool {
236237
if (lua_data.scheduled_for_removal)
237238
{
238239
const auto function_name_no_prefix = get_function_name_without_prefix(lua_data.unreal_function->GetFullName());
@@ -254,12 +255,19 @@ namespace RC
254255
return elem.get() == &lua_data;
255256
});
256257

257-
return;
258+
return true;
259+
}
260+
else
261+
{
262+
return false;
258263
}
259264
};
260265

261266
// Removes pre & post-hook callbacks if UnregisterHook was called in the pre-callback.
262-
remove_if_scheduled();
267+
if (remove_if_scheduled())
268+
{
269+
return;
270+
}
263271

264272
auto process_return_value = [&]() {
265273
// If 'nil' exists on the Lua stack, that means that the UFunction expected a return value but the Lua script didn't return anything

0 commit comments

Comments
 (0)