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

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

Issue 23646005: Improve GIF decoding performance (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: test data moved to Source/core/platform/image-decoders/testing 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..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();
« 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