From 6d7f7ea6985ab308c1c509b3cd46755290f24972 Mon Sep 17 00:00:00 2001 From: Asher Baker Date: Sat, 8 Nov 2014 02:00:40 +0000 Subject: [PATCH] Respect the docs. --- extension/extension.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extension/extension.cpp b/extension/extension.cpp index cc63018..cf3443c 100644 --- a/extension/extension.cpp +++ b/extension/extension.cpp @@ -93,6 +93,8 @@ void OnGameFrame(bool simulating) } } #elif defined _WINDOWS +void *vectoredHandler = NULL; + LONG CALLBACK BreakpadVectoredHandler(_In_ PEXCEPTION_POINTERS ExceptionInfo) { switch (ExceptionInfo->ExceptionRecord->ExceptionCode) @@ -238,7 +240,7 @@ bool Accelerator::SDK_OnLoad(char *error, size_t maxlength, bool late) handler = new google_breakpad::ExceptionHandler(std::wstring(buf, num_chars), NULL, dumpCallback, NULL, google_breakpad::ExceptionHandler::HANDLER_ALL); - AddVectoredExceptionHandler(0, BreakpadVectoredHandler); + vectoredHandler = AddVectoredExceptionHandler(0, BreakpadVectoredHandler); delete buf; #else @@ -253,7 +255,9 @@ void Accelerator::SDK_OnUnload() #if defined _LINUX g_pSM->RemoveGameFrameHook(OnGameFrame); #elif defined _WINDOWS - RemoveVectoredExceptionHandler(BreakpadVectoredHandler); + if (vectoredHandler) { + RemoveVectoredExceptionHandler(vectoredHandler); + } #else #error Bad platform. #endif