summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-27 04:03:40 +0000
committercpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-27 04:03:40 +0000
commit6eb0876213f6859369ea1c7247a350b0d70cc15b (patch)
treeb98a685f0e4ae7a6f4a234711aea7f4bf7edf533
parent90ef1313cb672e7da91312c4f7d3cdee41c7a767 (diff)
downloadchromium_src-6eb0876213f6859369ea1c7247a350b0d70cc15b.zip
chromium_src-6eb0876213f6859369ea1c7247a350b0d70cc15b.tar.gz
chromium_src-6eb0876213f6859369ea1c7247a350b0d70cc15b.tar.bz2
Add dcheck to CloseHandle()
- So we can catch invalid uses - Fix bug in ScopedHandle discovered by testing the dcheck. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1424 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/scoped_handle.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/base/scoped_handle.h b/base/scoped_handle.h
index 9112fbaa..49c9833 100644
--- a/base/scoped_handle.h
+++ b/base/scoped_handle.h
@@ -8,6 +8,7 @@
#include <windows.h>
#include "base/basictypes.h"
+#include "base/logging.h"
// Used so we always remember to close the handle. Example:
// ScopedHandle hfile(CreateFile(...));
@@ -43,7 +44,7 @@ class ScopedHandle {
Close();
// Windows is inconsistent about invalid handles, so we always use NULL
- if (handle_ != INVALID_HANDLE_VALUE)
+ if (new_handle != INVALID_HANDLE_VALUE)
handle_ = new_handle;
}
@@ -63,7 +64,9 @@ class ScopedHandle {
private:
void Close() {
if (handle_) {
- CloseHandle(handle_);
+ if (!::CloseHandle(handle_)) {
+ NOTREACHED();
+ }
handle_ = NULL;
}
}