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

Unified Diff: base/memory/discardable_shared_memory.cc

Issue 1741403002: base: Avoid calling VirtualAlloc with 0 length. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: keep most of unit test Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/memory/discardable_shared_memory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..acae29eabadec0a16de0ed5e0e43f672d3faddca 100644
--- a/base/memory/discardable_shared_memory.cc
+++ b/base/memory/discardable_shared_memory.cc
@@ -221,6 +221,10 @@ DiscardableSharedMemory::LockResult DiscardableSharedMemory::Lock(
DCHECK_EQ(locked_pages_.size(), locked_page_count_);
#endif
+ // Always behave as if memory was purged when trying to lock a 0 byte segment.
+ if (!length)
+ return PURGED;
+
// Pin pages if supported.
#if defined(OS_ANDROID)
SharedMemoryHandle handle = shared_memory_.handle();
« no previous file with comments | « no previous file | base/memory/discardable_shared_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698