Loading libs/ui/GraphicBufferAllocator.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -144,7 +144,8 @@ status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, // if stride has no meaning or is too large, // approximate size with the input width instead if (std::numeric_limits<size_t>::max() / height / (*stride) < static_cast<size_t>(bpp)) { if ((*stride) != 0 && std::numeric_limits<size_t>::max() / height / (*stride) < static_cast<size_t>(bpp)) { bufSize = static_cast<size_t>(width) * height * bpp; } else { bufSize = static_cast<size_t>((*stride)) * height * bpp; Loading libs/ui/tests/GraphicBufferAllocator_test.cpp +15 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,21 @@ TEST_F(GraphicBufferAllocatorTest, AllocateNoError) { ASSERT_EQ(kTestWidth, stride); } TEST_F(GraphicBufferAllocatorTest, AllocateBadStride) { TEST_F(GraphicBufferAllocatorTest, AllocateZeroStride) { android::PixelFormat format = PIXEL_FORMAT_RGBA_8888; uint32_t expectedStride = 0; mAllocator.setUpAllocateExpectations(NO_ERROR, expectedStride); uint32_t stride = 0; buffer_handle_t handle; // a divide by zero would cause a crash status_t err = mAllocator.allocate(kTestWidth, kTestHeight, format, kTestLayerCount, kTestUsage, &handle, &stride, 0, "GraphicBufferAllocatorTest"); ASSERT_EQ(NO_ERROR, err); ASSERT_EQ(expectedStride, stride); } TEST_F(GraphicBufferAllocatorTest, AllocateLargeStride) { uint32_t height = std::numeric_limits<uint32_t>::max(); uint32_t bpp = 4; android::PixelFormat format = PIXEL_FORMAT_RGBA_8888; Loading Loading
libs/ui/GraphicBufferAllocator.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -144,7 +144,8 @@ status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, // if stride has no meaning or is too large, // approximate size with the input width instead if (std::numeric_limits<size_t>::max() / height / (*stride) < static_cast<size_t>(bpp)) { if ((*stride) != 0 && std::numeric_limits<size_t>::max() / height / (*stride) < static_cast<size_t>(bpp)) { bufSize = static_cast<size_t>(width) * height * bpp; } else { bufSize = static_cast<size_t>((*stride)) * height * bpp; Loading
libs/ui/tests/GraphicBufferAllocator_test.cpp +15 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,21 @@ TEST_F(GraphicBufferAllocatorTest, AllocateNoError) { ASSERT_EQ(kTestWidth, stride); } TEST_F(GraphicBufferAllocatorTest, AllocateBadStride) { TEST_F(GraphicBufferAllocatorTest, AllocateZeroStride) { android::PixelFormat format = PIXEL_FORMAT_RGBA_8888; uint32_t expectedStride = 0; mAllocator.setUpAllocateExpectations(NO_ERROR, expectedStride); uint32_t stride = 0; buffer_handle_t handle; // a divide by zero would cause a crash status_t err = mAllocator.allocate(kTestWidth, kTestHeight, format, kTestLayerCount, kTestUsage, &handle, &stride, 0, "GraphicBufferAllocatorTest"); ASSERT_EQ(NO_ERROR, err); ASSERT_EQ(expectedStride, stride); } TEST_F(GraphicBufferAllocatorTest, AllocateLargeStride) { uint32_t height = std::numeric_limits<uint32_t>::max(); uint32_t bpp = 4; android::PixelFormat format = PIXEL_FORMAT_RGBA_8888; Loading