Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1551)

Unified Diff: Source/core/platform/image-decoders/gif/GIFImageDecoderTest.cpp

Issue 26336003: Reland r158910 "Improve GIF decoding performance" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add dir to export data files Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..9c89225c43feb9db17fca1e887c7b47851e5b63c 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 are invalid values that try to create a loop
+// in the dictionary. Decoding should fail, but not infinitely loop or corrupt memory.
+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());
+}
+
+// The image has an invalid LZW code that exceeds dictionary size. Decoding should fail.
+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();
« no previous file with comments | « Source/core/platform/image-decoders/gif/GIFImageDecoder.cpp ('k') | Source/core/platform/image-decoders/gif/GIFImageReader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698