Index: base/memory/discardable_shared_memory.cc |
diff --git a/base/memory/discardable_shared_memory.cc b/base/memory/discardable_shared_memory.cc |
index 7449f462e68ea4936b6c381239b316da59862594..65b6513b0a211371abca07d7dda3a8603460d130 100644 |
--- a/base/memory/discardable_shared_memory.cc |
+++ b/base/memory/discardable_shared_memory.cc |
@@ -232,7 +232,8 @@ DiscardableSharedMemory::LockResult DiscardableSharedMemory::Lock( |
} |
#elif defined(OS_WIN) |
if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
- if (!VirtualAlloc(reinterpret_cast<char*>(shared_memory_.memory()) + |
+ if (length && |
penny
2016/02/28 21:49:10
if (!length)
return PURGED;
Unlock is fine as i
reveman
2016/02/29 16:36:59
Done.
Note: memory segments are initially locked
|
+ !VirtualAlloc(reinterpret_cast<char*>(shared_memory_.memory()) + |
AlignToPageSize(sizeof(SharedState)) + offset, |
length, MEM_RESET_UNDO, PAGE_READWRITE)) { |
return PURGED; |
@@ -271,7 +272,8 @@ void DiscardableSharedMemory::Unlock(size_t offset, size_t length) { |
// function needs to match the Lock behaviour (MEM_RESET_UNDO) to properly |
// implement memory pinning. It needs to bias towards preserving the |
// contents of memory between an Unlock and next Lock. |
- if (!VirtualAlloc(reinterpret_cast<char*>(shared_memory_.memory()) + |
+ if (length && |
+ !VirtualAlloc(reinterpret_cast<char*>(shared_memory_.memory()) + |
AlignToPageSize(sizeof(SharedState)) + offset, |
length, MEM_RESET, PAGE_READWRITE)) { |
DPLOG(ERROR) << "VirtualAlloc() MEM_RESET failed in Unlock()"; |