summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gpu/command_buffer/service/command_buffer_service.cc3
-rw-r--r--gpu/command_buffer/service/command_buffer_service_unittest.cc4
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));