diff options
author | jbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-15 06:33:27 +0000 |
---|---|---|
committer | jbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-15 06:33:27 +0000 |
commit | 422d9354fdffc3eae15be4fc6769f777a4d507ff (patch) | |
tree | 4c01d31ac94ec39f48654e1308333930760e9fa6 /base/memory | |
parent | 561afe95a1feb1856178a3d20015b55887e33cd0 (diff) | |
download | chromium_src-422d9354fdffc3eae15be4fc6769f777a4d507ff.zip chromium_src-422d9354fdffc3eae15be4fc6769f777a4d507ff.tar.gz chromium_src-422d9354fdffc3eae15be4fc6769f777a4d507ff.tar.bz2 |
Revert 257300 "Disallow calling Map on currently-mapped SharedMe..."
Crashes PrintWebViewHelperTests.
> Disallow calling Map on currently-mapped SharedMemory
>
> This would leak the previous mapping of the memory.
>
> BUG=
>
> Review URL: https://codereview.chromium.org/195893022
TBR=jbauman@chromium.org
Review URL: https://codereview.chromium.org/200623007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257311 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/memory')
-rw-r--r-- | base/memory/shared_memory.h | 3 | ||||
-rw-r--r-- | base/memory/shared_memory_nacl.cc | 3 | ||||
-rw-r--r-- | base/memory/shared_memory_posix.cc | 3 | ||||
-rw-r--r-- | base/memory/shared_memory_unittest.cc | 14 | ||||
-rw-r--r-- | base/memory/shared_memory_win.cc | 3 |
5 files changed, 2 insertions, 24 deletions
diff --git a/base/memory/shared_memory.h b/base/memory/shared_memory.h index 27c3747..8e32e72 100644 --- a/base/memory/shared_memory.h +++ b/base/memory/shared_memory.h @@ -154,8 +154,7 @@ class BASE_EXPORT SharedMemory { // Maps the shared memory into the caller's address space. // Returns true on success, false otherwise. The memory address // is accessed via the memory() accessor. The mapped address is guaranteed to - // have an alignment of at least MAP_MINIMUM_ALIGNMENT. This method will fail - // if this object is currently mapped. + // have an alignment of at least MAP_MINIMUM_ALIGNMENT. bool Map(size_t bytes) { return MapAt(0, bytes); } diff --git a/base/memory/shared_memory_nacl.cc b/base/memory/shared_memory_nacl.cc index 39625ee..7647400 100644 --- a/base/memory/shared_memory_nacl.cc +++ b/base/memory/shared_memory_nacl.cc @@ -91,9 +91,6 @@ bool SharedMemory::MapAt(off_t offset, size_t bytes) { if (bytes > static_cast<size_t>(std::numeric_limits<int>::max())) return false; - if (memory_) - return false; - memory_ = mmap(NULL, bytes, PROT_READ | (read_only_ ? 0 : PROT_WRITE), MAP_SHARED, mapped_file_, offset); diff --git a/base/memory/shared_memory_posix.cc b/base/memory/shared_memory_posix.cc index 1756c29..1a90847 100644 --- a/base/memory/shared_memory_posix.cc +++ b/base/memory/shared_memory_posix.cc @@ -279,9 +279,6 @@ bool SharedMemory::MapAt(off_t offset, size_t bytes) { if (bytes > static_cast<size_t>(std::numeric_limits<int>::max())) return false; - if (memory_) - return false; - #if defined(OS_ANDROID) // On Android, Map can be called with a size and offset of zero to use the // ashmem-determined size. diff --git a/base/memory/shared_memory_unittest.cc b/base/memory/shared_memory_unittest.cc index f2a9e74..b8999f6 100644 --- a/base/memory/shared_memory_unittest.cc +++ b/base/memory/shared_memory_unittest.cc @@ -477,6 +477,7 @@ 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)); @@ -496,19 +497,6 @@ 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) { diff --git a/base/memory/shared_memory_win.cc b/base/memory/shared_memory_win.cc index cc177ab..c9d603e 100644 --- a/base/memory/shared_memory_win.cc +++ b/base/memory/shared_memory_win.cc @@ -164,9 +164,6 @@ bool SharedMemory::MapAt(off_t offset, size_t bytes) { if (bytes > static_cast<size_t>(std::numeric_limits<int>::max())) return false; - if (memory_) - return false; - memory_ = MapViewOfFile(mapped_file_, read_only_ ? FILE_MAP_READ : FILE_MAP_READ | FILE_MAP_WRITE, |