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

Unified Diff: base/memory/shared_memory_unittest.cc

Issue 203123009: Disallow calling Map on currently-mapped SharedMemory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | « base/memory/shared_memory_posix.cc ('k') | base/memory/shared_memory_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/shared_memory_unittest.cc
diff --git a/base/memory/shared_memory_unittest.cc b/base/memory/shared_memory_unittest.cc
index b8999f6f3c59832811c9e5924d82f1cece638b5b..f2a9e7480fc43c7fad8f7e5bed3e5f6d285c3e97 100644
--- a/base/memory/shared_memory_unittest.cc
+++ b/base/memory/shared_memory_unittest.cc
@@ -477,7 +477,6 @@ TEST(SharedMemoryTest, MapAt) {
SharedMemory memory;
ASSERT_TRUE(memory.CreateAndMapAnonymous(kDataSize));
- ASSERT_TRUE(memory.Map(kDataSize));
uint32* ptr = static_cast<uint32*>(memory.memory());
ASSERT_NE(ptr, static_cast<void*>(NULL));
@@ -497,6 +496,19 @@ TEST(SharedMemoryTest, MapAt) {
}
}
+TEST(SharedMemoryTest, MapTwice) {
+ const uint32 kDataSize = 1024;
+ SharedMemory memory;
+ bool rv = memory.CreateAndMapAnonymous(kDataSize);
+ EXPECT_TRUE(rv);
+
+ void* old_address = memory.memory();
+
+ rv = memory.Map(kDataSize);
+ EXPECT_FALSE(rv);
+ EXPECT_EQ(old_address, memory.memory());
+}
+
#if defined(OS_POSIX)
// Create a shared memory object, mmap it, and mprotect it to PROT_EXEC.
TEST(SharedMemoryTest, AnonymousExecutable) {
« no previous file with comments | « base/memory/shared_memory_posix.cc ('k') | base/memory/shared_memory_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698