Commit 98c74958 authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

WebImage::framesFromData should skip corrupted frames

https://bugs.webkit.org/show_bug.cgi?id=98214

Patch by Peter Kotwicz <pkotwicz@google.com> on 2012-10-03
Reviewed by Adam Barth.

WebImage::framesFromData() should only return bitmaps for valid frames
of a .ico file.

* src/WebImageSkia.cpp:
(WebKit::WebImage::framesFromData):
* tests/WebImageTest.cpp:
(WebKit::TEST):
(WebKit):
* tests/data/valid_header_missing_bitmap.ico: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130268 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ca1aea26
2012-10-03 Peter Kotwicz <pkotwicz@google.com>
WebImage::framesFromData should skip corrupted frames
https://bugs.webkit.org/show_bug.cgi?id=98214
Reviewed by Adam Barth.
WebImage::framesFromData() should only return bitmaps for valid frames
of a .ico file.
* src/WebImageSkia.cpp:
(WebKit::WebImage::framesFromData):
* tests/WebImageTest.cpp:
(WebKit::TEST):
(WebKit):
* tests/data/valid_header_missing_bitmap.ico: Added.
2012-10-02 Yury Semikhatsky <yurys@chromium.org>
Provide memory instrumentation for HashCountedSet
......
......@@ -125,7 +125,7 @@ WebVector<WebImage> WebImage::framesFromData(const WebData& data)
continue;
OwnPtr<NativeImageSkia> image = adoptPtr(frame->asNewNativeImage());
if (image.get())
if (image.get() && image->isDataComplete())
frames.append(WebImage(image->bitmap()));
}
......
......@@ -88,6 +88,15 @@ TEST(WebImageTest, ICOImage)
EXPECT_EQ(SkColorSetARGB(255, 0, 0, 0), images[1].getSkBitmap().getColor(0, 0));
}
TEST(WebImageTest, ICOValidHeaderMissingBitmap)
{
RefPtr<SharedBuffer> data = readFile("valid_header_missing_bitmap.ico");
ASSERT_TRUE(data.get());
WebVector<WebImage> images = WebImage::framesFromData(WebData(data));
ASSERT_TRUE(images.isEmpty());
}
TEST(WebImageTest, BadImage)
{
const char badImage[] = "hello world";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment