Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: base/win/scoped_process_information.cc

Issue 10447108: Base: Crash when failing to close a process/thread handle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/win/scoped_process_information.h" 5 #include "base/win/scoped_process_information.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/win/scoped_handle.h" 8 #include "base/win/scoped_handle.h"
9 9
10 namespace base { 10 namespace base {
11 namespace win { 11 namespace win {
12 12
13 namespace { 13 namespace {
14 14
15 // Closes the provided handle if it is not NULL. 15 // Closes the provided handle if it is not NULL.
16 void CheckAndCloseHandle(HANDLE handle) { 16 void CheckAndCloseHandle(HANDLE handle) {
17 if (!handle) 17 if (!handle)
18 return; 18 return;
19 if (::CloseHandle(handle)) 19 if (::CloseHandle(handle))
20 return; 20 return;
21 DPCHECK(false) << "Failed to close a handle."; 21 CHECK(false);
22 } 22 }
23 23
24 // Duplicates source into target, returning true upon success. |target| is 24 // Duplicates source into target, returning true upon success. |target| is
25 // guaranteed to be untouched in case of failure. Succeeds with no side-effects 25 // guaranteed to be untouched in case of failure. Succeeds with no side-effects
26 // if source is NULL. 26 // if source is NULL.
27 bool CheckAndDuplicateHandle(HANDLE source, HANDLE* target) { 27 bool CheckAndDuplicateHandle(HANDLE source, HANDLE* target) {
28 if (!source) 28 if (!source)
29 return true; 29 return true;
30 30
31 HANDLE temp = NULL; 31 HANDLE temp = NULL;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 void ScopedProcessInformation::Reset() { 118 void ScopedProcessInformation::Reset() {
119 process_information_.hThread = NULL; 119 process_information_.hThread = NULL;
120 process_information_.hProcess = NULL; 120 process_information_.hProcess = NULL;
121 process_information_.dwProcessId = 0; 121 process_information_.dwProcessId = 0;
122 process_information_.dwThreadId = 0; 122 process_information_.dwThreadId = 0;
123 } 123 }
124 124
125 } // namespace win 125 } // namespace win
126 } // namespace base 126 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698