From 38af8d7035af1c6c5566c9488315490ede986875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Mon, 30 Jan 2017 19:54:16 +0100 Subject: [PATCH] Fixed SEH deregistration on Windows Should fix #796 --- include/internal/catch_fatal_condition.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/internal/catch_fatal_condition.hpp b/include/internal/catch_fatal_condition.hpp index 0bdc79b7..b9f8c694 100644 --- a/include/internal/catch_fatal_condition.hpp +++ b/include/internal/catch_fatal_condition.hpp @@ -59,9 +59,9 @@ namespace Catch { // 32k seems enough for Catch to handle stack overflow, // but the value was found experimentally, so there is no strong guarantee - FatalConditionHandler():m_isSet(true), m_guaranteeSize(32 * 1024) { + FatalConditionHandler():m_isSet(true), m_guaranteeSize(32 * 1024), m_exceptionHandlerHandle(CATCH_NULL) { // Register as first handler in current chain - AddVectoredExceptionHandler(1, handleVectoredException); + m_exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException); // Pass in guarantee size to be filled SetThreadStackGuarantee(&m_guaranteeSize); } @@ -69,8 +69,9 @@ namespace Catch { void reset() { if (m_isSet) { // Unregister handler and restore the old guarantee - RemoveVectoredExceptionHandler(handleVectoredException); + RemoveVectoredExceptionHandler(m_exceptionHandlerHandle); SetThreadStackGuarantee(&m_guaranteeSize); + m_exceptionHandlerHandle = CATCH_NULL; m_isSet = false; } } @@ -81,6 +82,7 @@ namespace Catch { private: bool m_isSet; ULONG m_guaranteeSize; + PVOID m_exceptionHandlerHandle; }; } // namespace Catch