gwin32: Do not register a crash handler unless requested

Fixes https://gitlab.gnome.org/GNOME/glib/issues/2025
This commit is contained in:
Nirbheek Chauhan 2020-02-18 23:04:39 +05:30
parent 6919a719c1
commit 0cfbe8f3b0

View File

@ -1208,6 +1208,14 @@ g_crash_handler_win32_init (void)
if (WinVEH_handle != NULL) if (WinVEH_handle != NULL)
return; return;
/* Do not register an exception handler if we're not supposed to catch any
* exceptions. Exception handlers are considered dangerous to use, and can
* break advanced exception handling such as in CLRs like C# or other managed
* code. See: https://blogs.msdn.microsoft.com/jmstall/2006/05/24/beware-of-the-vectored-exception-handler-and-managed-code/
*/
if (getenv ("G_DEBUGGER") == NULL && getenv("G_VEH_CATCH") == NULL)
return;
WinVEH_handle = AddVectoredExceptionHandler (0, &g_win32_veh_handler); WinVEH_handle = AddVectoredExceptionHandler (0, &g_win32_veh_handler);
} }