diff options
author | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-05 07:20:06 +0000 |
---|---|---|
committer | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-05 07:20:06 +0000 |
commit | 1876f5e51c5c27b33e02914f34ad9e23485700d6 (patch) | |
tree | 8eb4bfd9f292fee49d36e881dfbd84185fc1fc7b /content/common | |
parent | f353677e39da2a51c6071cc468fe0da801889176 (diff) | |
download | chromium_src-1876f5e51c5c27b33e02914f34ad9e23485700d6.zip chromium_src-1876f5e51c5c27b33e02914f34ad9e23485700d6.tar.gz chromium_src-1876f5e51c5c27b33e02914f34ad9e23485700d6.tar.bz2 |
Revert 261817 "cc: Remove all usage of GetArea() from production..."
Suspected of causing failures on Linux CrOS ASan LSan:
http://build.chromium.org/p/chromium.memory/builders/Linux%20Chromium%20OS%20ASan%2BLSan%20Tests%20%283%29/builds/702
http://build.chromium.org/p/chromium.memory/builders/Linux%20Chromium%20OS%20ASan%2BLSan%20Tests%20%282%29/builds/664
http://build.chromium.org/p/chromium.memory/builders/Linux%20Chromium%20OS%20ASan%2BLSan%20Tests%20%281%29/builds/702
> cc: Remove all usage of GetArea() from production code in cc
>
> Consolidate the calls to turn gfx::Size into a number of bytes onto
> the cc::SharedBitmap class. The class offers the following methods:
> 1. Get a size_t bytes and bool saying if you overflowed or not.
> 2. Get a size_t bytes and crash if you overflow.
> 3. Get a size_t bytes and don't check for overflow.
> 4. Tell me if the gfx::Size would overflow to create the size_t bytes.
>
> These were the use cases I found in the existing code, plus the
> addition of case 2. A few places that were finding the size_t bytes
> without looking for overflow (case 3), from a previously-unchecked
> gfx::Size, were changed to crash on overflow instead (case 2).
>
> R=jbauman@chromium.org, piman@chromium.org
> BUG=348332
>
> Review URL: https://codereview.chromium.org/221523003
TBR=danakj@chromium.org
Review URL: https://codereview.chromium.org/226693005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261972 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common')
-rw-r--r-- | content/common/cc_messages.cc | 5 | ||||
-rw-r--r-- | content/common/host_shared_bitmap_manager.cc | 2 | ||||
-rw-r--r-- | content/common/host_shared_bitmap_manager_unittest.cc | 8 |
3 files changed, 7 insertions, 8 deletions
diff --git a/content/common/cc_messages.cc b/content/common/cc_messages.cc index 5279d4c..40e2441 100644 --- a/content/common/cc_messages.cc +++ b/content/common/cc_messages.cc @@ -755,7 +755,7 @@ void ParamTraits<cc::DelegatedFrameData>::Log(const param_type& p, void ParamTraits<cc::SoftwareFrameData>::Write(Message* m, const param_type& p) { - DCHECK(cc::SharedBitmap::VerifySizeInBytes(p.size)); + DCHECK(p.CheckedSizeInBytes().IsValid()); m->Reserve(sizeof(cc::SoftwareFrameData)); WriteParam(m, p.id); @@ -769,8 +769,7 @@ bool ParamTraits<cc::SoftwareFrameData>::Read(const Message* m, param_type* p) { if (!ReadParam(m, iter, &p->id)) return false; - if (!ReadParam(m, iter, &p->size) || - !cc::SharedBitmap::VerifySizeInBytes(p->size)) + if (!ReadParam(m, iter, &p->size) || !p->CheckedSizeInBytes().IsValid()) return false; if (!ReadParam(m, iter, &p->damage_rect)) return false; diff --git a/content/common/host_shared_bitmap_manager.cc b/content/common/host_shared_bitmap_manager.cc index 88d9f65..aa0cd81 100644 --- a/content/common/host_shared_bitmap_manager.cc +++ b/content/common/host_shared_bitmap_manager.cc @@ -62,7 +62,7 @@ scoped_ptr<cc::SharedBitmap> HostSharedBitmapManager::GetSharedBitmapFromId( BitmapData* data = it->second.get(); size_t bitmap_size; - if (!cc::SharedBitmap::SizeInBytes(size, &bitmap_size) || + if (!cc::SharedBitmap::GetSizeInBytes(size, &bitmap_size) || bitmap_size > data->buffer_size) return scoped_ptr<cc::SharedBitmap>(); diff --git a/content/common/host_shared_bitmap_manager_unittest.cc b/content/common/host_shared_bitmap_manager_unittest.cc index ed0ddba..1f7d8dd 100644 --- a/content/common/host_shared_bitmap_manager_unittest.cc +++ b/content/common/host_shared_bitmap_manager_unittest.cc @@ -17,7 +17,7 @@ class HostSharedBitmapManagerTest : public testing::Test { TEST_F(HostSharedBitmapManagerTest, TestCreate) { gfx::Size bitmap_size(1, 1); size_t size_in_bytes; - EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes)); + EXPECT_TRUE(cc::SharedBitmap::GetSizeInBytes(bitmap_size, &size_in_bytes)); scoped_ptr<base::SharedMemory> bitmap(new base::SharedMemory()); bitmap->CreateAndMapAnonymous(size_in_bytes); memset(bitmap->memory(), 0xff, size_in_bytes); @@ -76,7 +76,7 @@ TEST_F(HostSharedBitmapManagerTest, TestCreate) { TEST_F(HostSharedBitmapManagerTest, TestCreateForChild) { gfx::Size bitmap_size(1, 1); size_t size_in_bytes; - EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes)); + EXPECT_TRUE(cc::SharedBitmap::GetSizeInBytes(bitmap_size, &size_in_bytes)); cc::SharedBitmapId id = cc::SharedBitmap::GenerateId(); base::SharedMemoryHandle handle; manager_->AllocateSharedBitmapForChild( @@ -97,7 +97,7 @@ TEST_F(HostSharedBitmapManagerTest, TestCreateForChild) { TEST_F(HostSharedBitmapManagerTest, RemoveProcess) { gfx::Size bitmap_size(1, 1); size_t size_in_bytes; - EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes)); + EXPECT_TRUE(cc::SharedBitmap::GetSizeInBytes(bitmap_size, &size_in_bytes)); scoped_ptr<base::SharedMemory> bitmap(new base::SharedMemory()); bitmap->CreateAndMapAnonymous(size_in_bytes); memset(bitmap->memory(), 0xff, size_in_bytes); @@ -131,7 +131,7 @@ TEST_F(HostSharedBitmapManagerTest, RemoveProcess) { TEST_F(HostSharedBitmapManagerTest, AddDuplicate) { gfx::Size bitmap_size(1, 1); size_t size_in_bytes; - EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes)); + EXPECT_TRUE(cc::SharedBitmap::GetSizeInBytes(bitmap_size, &size_in_bytes)); scoped_ptr<base::SharedMemory> bitmap(new base::SharedMemory()); bitmap->CreateAndMapAnonymous(size_in_bytes); memset(bitmap->memory(), 0xff, size_in_bytes); |