Commit 6538a901 authored by Matthew Cary's avatar Matthew Cary Committed by Commit Bot

media/base WritableUnalignedMapping fix.

Use the underlying handle size when wrapping a legacy shared memory instance.

Bug: 849207
Change-Id: Ibbf62ebbea5a95d64d84a0faf2042f639be5b820
Reviewed-on: https://chromium-review.googlesource.com/1118268Reviewed-by: default avatarAlexandr Ilin <alexilin@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: Matthew Cary <mattcary@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571846}
parent 666b3277
...@@ -115,7 +115,7 @@ WritableUnalignedMapping::WritableUnalignedMapping( ...@@ -115,7 +115,7 @@ WritableUnalignedMapping::WritableUnalignedMapping(
: WritableUnalignedMapping( : WritableUnalignedMapping(
mojo::UnwrapUnsafeSharedMemoryRegion(mojo::WrapSharedMemoryHandle( mojo::UnwrapUnsafeSharedMemoryRegion(mojo::WrapSharedMemoryHandle(
handle, handle,
size, handle.GetSize(),
mojo::UnwrappedSharedMemoryHandleProtection::kReadWrite)), mojo::UnwrappedSharedMemoryHandleProtection::kReadWrite)),
size, size,
offset) {} offset) {}
......
...@@ -129,6 +129,13 @@ TEST(WritableUnalignedMappingTest, Map_Unaligned) { ...@@ -129,6 +129,13 @@ TEST(WritableUnalignedMappingTest, Map_Unaligned) {
EXPECT_EQ(0, memcmp(shm.memory(), kData, kDataSize)); EXPECT_EQ(0, memcmp(shm.memory(), kData, kDataSize));
} }
TEST(WritableUnalignedMappingTest, Map_UnalignedHandle) {
auto region = CreateHandle(kUnalignedData, kUnalignedDataSize);
WritableUnalignedMapping shm(region, kDataSize, kUnalignedOffset);
ASSERT_TRUE(shm.IsValid());
EXPECT_EQ(0, memcmp(shm.memory(), kData, kDataSize));
}
TEST(WritableUnalignedMappingTest, Map_InvalidRegion) { TEST(WritableUnalignedMappingTest, Map_InvalidRegion) {
base::UnsafeSharedMemoryRegion region; base::UnsafeSharedMemoryRegion region;
WritableUnalignedMapping shm(region, kDataSize, 0); WritableUnalignedMapping shm(region, kDataSize, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment