From ff4b800bb240a8af115c387ce84caf10c449f6b0 Mon Sep 17 00:00:00 2001 From: Gabriele Svelto Date: Tue, 15 Nov 2022 21:18:42 +0000 Subject: [PATCH] Bug 1775039 - Do not crash when failing to set Breakpad's exception handler thread's name r=KrisWright Differential Revision: https://phabricator.services.mozilla.com/D161642 --- .../breakpad-client/windows/handler/exception_handler.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/toolkit/crashreporter/breakpad-client/windows/handler/exception_handler.cc b/toolkit/crashreporter/breakpad-client/windows/handler/exception_handler.cc index e697415889cf..281593e4b4a4 100644 --- a/toolkit/crashreporter/breakpad-client/windows/handler/exception_handler.cc +++ b/toolkit/crashreporter/breakpad-client/windows/handler/exception_handler.cc @@ -408,11 +408,13 @@ typedef HRESULT(WINAPI* SetThreadDescriptionPtr)(HANDLE hThread, // static DWORD ExceptionHandler::ExceptionHandlerThreadMain(void* lpParameter) { HMODULE handle = ::GetModuleHandle(L"Kernel32.dll"); - if (FARPROC address = ::GetProcAddress(handle, "SetThreadDescription")) { - auto SetThreadDescriptionFunc = - reinterpret_cast(address); - SetThreadDescriptionFunc(::GetCurrentThread(), - L"Breakpad ExceptionHandler"); + if (handle) { + if (FARPROC address = ::GetProcAddress(handle, "SetThreadDescription")) { + auto SetThreadDescriptionFunc = + reinterpret_cast(address); + SetThreadDescriptionFunc(::GetCurrentThread(), + L"Breakpad ExceptionHandler"); + } } ExceptionHandler* self = reinterpret_cast(lpParameter); -- 2.11.4.GIT