diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-22 21:38:19 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-22 21:38:19 +0000 |
commit | a9e3400153536dceeaec23e0b3d8f0b82f34ae57 (patch) | |
tree | dc86878fc60dd4714413255a46706c0dcc1910b2 /gpu/command_buffer | |
parent | a6c92911279cec35ecb0906f860b4aeea179267b (diff) | |
download | chromium_src-a9e3400153536dceeaec23e0b3d8f0b82f34ae57.zip chromium_src-a9e3400153536dceeaec23e0b3d8f0b82f34ae57.tar.gz chromium_src-a9e3400153536dceeaec23e0b3d8f0b82f34ae57.tar.bz2 |
Added check for negative size to CommandBufferService.
TEST=regression test
BUG=35931
Review URL: http://codereview.chromium.org/652064
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39635 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer')
-rw-r--r-- | gpu/command_buffer/service/command_buffer_service.cc | 3 | ||||
-rw-r--r-- | gpu/command_buffer/service/command_buffer_service_unittest.cc | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/gpu/command_buffer/service/command_buffer_service.cc b/gpu/command_buffer/service/command_buffer_service.cc index 90503ed..797d9a5 100644 --- a/gpu/command_buffer/service/command_buffer_service.cc +++ b/gpu/command_buffer/service/command_buffer_service.cc @@ -31,7 +31,7 @@ bool CommandBufferService::Initialize(int32 size) { if (ring_buffer_.get()) return false; - if (size == 0 || size > kMaxCommandBufferSize) + if (size <= 0 || size > kMaxCommandBufferSize) return false; size_ = size; @@ -43,6 +43,7 @@ bool CommandBufferService::Initialize(int32 size) { return true; } + size_ = 0; ring_buffer_.reset(); return false; } diff --git a/gpu/command_buffer/service/command_buffer_service_unittest.cc b/gpu/command_buffer/service/command_buffer_service_unittest.cc index 7a116c0..713c9a5 100644 --- a/gpu/command_buffer/service/command_buffer_service_unittest.cc +++ b/gpu/command_buffer/service/command_buffer_service_unittest.cc @@ -76,6 +76,10 @@ TEST_F(CommandBufferServiceTest, InitializationFailsIfSizeOutOfRange) { CommandBuffer::kMaxCommandBufferSize + 1)); } +TEST_F(CommandBufferServiceTest, InitializationFailsIfSizeIsNegative) { + EXPECT_FALSE(command_buffer_->Initialize(-1)); +} + TEST_F(CommandBufferServiceTest, InitializeFailsSecondTime) { EXPECT_TRUE(command_buffer_->Initialize(1024)); EXPECT_FALSE(command_buffer_->Initialize(1024)); |