Index: base/memory/shared_memory_win.cc |
diff --git a/base/memory/shared_memory_win.cc b/base/memory/shared_memory_win.cc |
index 5f706fe648598642584903f39a5aa40786acc88d..3c9f4b77d08710f407f2c6fb9406bf07454a1a5d 100644 |
--- a/base/memory/shared_memory_win.cc |
+++ b/base/memory/shared_memory_win.cc |
@@ -74,7 +74,7 @@ SharedMemory::~SharedMemory() { |
// static |
bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { |
- return handle != NULL; |
+ return handle != NULL && handle != INVALID_HANDLE_VALUE; |
rvargas (doing something else)
2015/09/18 22:36:25
<rant>
I know I'm grumpy, but this pattern doesn't
|
} |
// static |
@@ -84,7 +84,7 @@ SharedMemoryHandle SharedMemory::NULLHandle() { |
// static |
void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { |
- DCHECK(handle != NULL); |
+ DCHECK(IsHandleValid(handle)); |
rvargas (doing something else)
2015/09/18 22:36:25
ScopedHandle closer(handle);
<rant> receiving con
|
::CloseHandle(handle); |
} |
@@ -178,14 +178,14 @@ bool SharedMemory::Delete(const std::string& name) { |
} |
bool SharedMemory::Open(const std::string& name, bool read_only) { |
- DCHECK(!mapped_file_); |
+ DCHECK(!IsHandleValid(mapped_file_)); |
rvargas (doing something else)
2015/09/18 22:36:25
DCHECK(mapped_file_.Isvalid());
(+ making the mem
|
name_ = ASCIIToUTF16(name); |
read_only_ = read_only; |
mapped_file_ = OpenFileMapping( |
read_only_ ? FILE_MAP_READ : FILE_MAP_READ | FILE_MAP_WRITE, |
false, name_.empty() ? NULL : name_.c_str()); |
- if (mapped_file_ != NULL) { |
+ if (IsHandleValid(mapped_file_)) { |
// Note: size_ is not set in this case. |
return true; |
} |
@@ -193,7 +193,7 @@ bool SharedMemory::Open(const std::string& name, bool read_only) { |
} |
bool SharedMemory::MapAt(off_t offset, size_t bytes) { |
- if (mapped_file_ == NULL) |
+ if (!IsHandleValid(mapped_file_)) |
return false; |
if (bytes > static_cast<size_t>(std::numeric_limits<int>::max())) |
@@ -259,7 +259,7 @@ bool SharedMemory::ShareToProcessCommon(ProcessHandle process, |
void SharedMemory::Close() { |
- if (mapped_file_ != NULL) { |
+ if (IsHandleValid(mapped_file_)) { |
CloseHandle(mapped_file_); |
mapped_file_ = NULL; |
} |