From 863a59a8e2095cf4ebc86bcb325e30dbda91bbbe Mon Sep 17 00:00:00 2001 From: xianwei zheng Date: Thu, 1 Dec 2022 13:57:09 +0800 Subject: [PATCH] Thunk: Crash on XSetErrorHandler(NULL) (#2190) * BUGFIX:Adding the nullptr check to FinalizeHostTrampolineForGuestFunction. It will lead crash on interpreter code set function nullptr callback. eg. XSetErrorHandler(NULL) * fix #2189 --- External/FEXCore/Source/Interface/HLE/Thunks/Thunks.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/External/FEXCore/Source/Interface/HLE/Thunks/Thunks.cpp b/External/FEXCore/Source/Interface/HLE/Thunks/Thunks.cpp index 446176071..730184dbb 100644 --- a/External/FEXCore/Source/Interface/HLE/Thunks/Thunks.cpp +++ b/External/FEXCore/Source/Interface/HLE/Thunks/Thunks.cpp @@ -431,6 +431,9 @@ namespace FEXCore { FEX_DEFAULT_VISIBILITY void FinalizeHostTrampolineForGuestFunction(HostToGuestTrampolinePtr* TrampolineAddress, void* HostPacker) { + + if (TrampolineAddress == nullptr) return; + auto& Trampoline = GetInstanceInfo(TrampolineAddress); LOGMAN_THROW_A_FMT(Trampoline.CallCallback == (uintptr_t)&ThunkHandler_impl::CallCallback,