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
CrOS-Libchrome-Original-Commit: 6eb0876213f6859369ea1c7247a350b0d70cc15b
diff --git a/base/scoped_handle.h b/base/scoped_handle.h
index 9112fba..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 @@
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 @@
private:
void Close() {
if (handle_) {
- CloseHandle(handle_);
+ if (!::CloseHandle(handle_)) {
+ NOTREACHED();
+ }
handle_ = NULL;
}
}