Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(10459)

Unified Diff: client/windows/handler/exception_handler.cc

Issue 491002: Not checking properly the return value of SuspendThread on Windows (Closed) Base URL: http://google-breakpad.googlecode.com/svn/trunk/src/
Patch Set: Using C++ cast instead of C-style Created 12 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/windows/handler/exception_handler.cc
===================================================================
--- client/windows/handler/exception_handler.cc (revision 1073)
+++ client/windows/handler/exception_handler.cc (working copy)
@@ -44,6 +44,9 @@
static const int kWaitForHandlerThreadMs = 60000;
static const int kExceptionHandlerThreadInitialStackSize = 64 * 1024;
+// As documented on MSDN, on failure SuspendThread returns (DWORD) -1
+static const DWORD kFailedToSuspendThread = static_cast<DWORD>(-1);
+
// This is passed as the context to the MinidumpWriteDump callback.
typedef struct {
AppMemoryList::const_iterator iter;
@@ -747,7 +750,7 @@
EXCEPTION_RECORD ex;
CONTEXT ctx;
EXCEPTION_POINTERS exinfo = { NULL, NULL };
- DWORD last_suspend_count = -1;
+ DWORD last_suspend_count = kFailedToSuspendThread;
HANDLE child_thread_handle = OpenThread(THREAD_GET_CONTEXT |
THREAD_QUERY_INFORMATION |
THREAD_SUSPEND_RESUME,
@@ -757,7 +760,7 @@
// non-fatal error.
if (child_thread_handle != NULL) {
last_suspend_count = SuspendThread(child_thread_handle);
- if (last_suspend_count >= 0) {
+ if (last_suspend_count != kFailedToSuspendThread) {
ctx.ContextFlags = CONTEXT_ALL;
if (GetThreadContext(child_thread_handle, &ctx)) {
memset(&ex, 0, sizeof(ex));
@@ -780,7 +783,7 @@
exinfo.ExceptionRecord ? &exinfo : NULL,
NULL, child, false);
- if (last_suspend_count >= 0) {
+ if (last_suspend_count != kFailedToSuspendThread) {
ResumeThread(child_thread_handle);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 1004:630ec63f810e-tainted