From 6a2e20ad14ac2fa09ddd5a81a8324de57bbf680b Mon Sep 17 00:00:00 2001 From: perkj Date: Wed, 30 Nov 2016 04:53:08 -0800 Subject: [PATCH] Make sure GetLastError on a PlatformThread return an error that is relevant to the thread. BUG=none Review-Url: https://codereview.webrtc.org/2541003002 Cr-Commit-Position: refs/heads/master@{#15328} --- webrtc/base/platform_thread.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/webrtc/base/platform_thread.cc b/webrtc/base/platform_thread.cc index 286bee95f1..0b025f2af0 100644 --- a/webrtc/base/platform_thread.cc +++ b/webrtc/base/platform_thread.cc @@ -119,6 +119,11 @@ PlatformThread::~PlatformThread() { #if defined(WEBRTC_WIN) DWORD WINAPI PlatformThread::StartThread(void* param) { + // The GetLastError() function only returns valid results when it is called + // after a Win32 API function that returns a "failed" result. A crash dump + // contains the result from GetLastError() and to make sure it does not + // falsely report a Windows error we call SetLastError here. + ::SetLastError(ERROR_SUCCESS); static_cast(param)->Run(); return 0; }