Chromium Code Reviews| Index: Source/core/platform/image-decoders/gif/GIFImageDecoderTest.cpp |
| diff --git a/Source/core/platform/image-decoders/gif/GIFImageDecoderTest.cpp b/Source/core/platform/image-decoders/gif/GIFImageDecoderTest.cpp |
| index 356be68f5ddf41cb8631329d2564805d024778cb..299eae0a09235622ee413333ed675740c2942c19 100644 |
| --- a/Source/core/platform/image-decoders/gif/GIFImageDecoderTest.cpp |
| +++ b/Source/core/platform/image-decoders/gif/GIFImageDecoderTest.cpp |
| @@ -452,6 +452,33 @@ TEST(GIFImageDecoderTest, resumePartialDecodeAfterClearFrameBufferCache) |
| EXPECT_EQ(baselineHashes[0], hashSkBitmap(firstFrame->getSkBitmap())); |
| } |
| +// The first LZW codes in the image is invalid that try to create a loop in |
| +// dictionary. Decoding should fail, but not infinitely loop or corrupt memory. |
|
Peter Kasting
2013/10/03 17:52:27
Nit: This first sentence got quite mangled and is
|
| +TEST(GIFImageDecoderTest, badInitialCode) |
| +{ |
| + RefPtr<SharedBuffer> testData = readFile("/Source/core/platform/image-decoders/testing/bad-initial-code.gif"); |
| + ASSERT_TRUE(testData.get()); |
| + |
| + OwnPtr<GIFImageDecoder> testDecoder(createDecoder()); |
| + testDecoder->setData(testData.get(), true); |
| + EXPECT_EQ(1u, testDecoder->frameCount()); |
| + ASSERT_TRUE(testDecoder->frameBufferAtIndex(0)); |
| + EXPECT_TRUE(testDecoder->failed()); |
| +} |
| + |
| +// Image has an invalid LZW code that exceeds dictionary size. Decoding should fail. |
|
Peter Kasting
2013/10/03 17:52:27
Nit: Add missing articles: "The image has an inval
|
| +TEST(GIFImageDecoderTest, badCode) |
| +{ |
| + RefPtr<SharedBuffer> testData = readFile("/Source/core/platform/image-decoders/testing/bad-code.gif"); |
| + ASSERT_TRUE(testData.get()); |
| + |
| + OwnPtr<GIFImageDecoder> testDecoder(createDecoder()); |
| + testDecoder->setData(testData.get(), true); |
| + EXPECT_EQ(1u, testDecoder->frameCount()); |
| + ASSERT_TRUE(testDecoder->frameBufferAtIndex(0)); |
| + EXPECT_TRUE(testDecoder->failed()); |
| +} |
| + |
| TEST(GIFImageDecoderTest, invalidDisposalMethod) |
| { |
| OwnPtr<GIFImageDecoder> decoder = createDecoder(); |