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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp

Issue 2761303003: Make ICO fail on truncated data (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoderTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
index 2c1dc2bd8137c09771f9a035490278a86b72a810..2d0ca3235a8354309fe855fb92188f735242c0bb 100644
--- a/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
@@ -216,15 +216,20 @@ bool ICOImageDecoder::decodeAtIndex(size_t index) {
dirEntry.m_imageOffset));
setDataForPNGDecoderAtIndex(index);
}
- // Fail if the size the PNGImageDecoder calculated does not match the size
- // in the directory.
auto* pngDecoder = m_pngDecoders[index].get();
- if (pngDecoder->isSizeAvailable() && pngDecoder->size() != dirEntry.m_size)
+ if (pngDecoder->isSizeAvailable()) {
+ // Fail if the size the PNGImageDecoder calculated does not match the size
+ // in the directory.
+ if (pngDecoder->size() != dirEntry.m_size)
+ return setFailed();
+
+ const auto* frame = pngDecoder->frameBufferAtIndex(0);
+ if (frame)
+ m_frameBufferCache[index] = *frame;
+ }
+ if (pngDecoder->failed())
return setFailed();
- const auto* frame = pngDecoder->frameBufferAtIndex(0);
- if (frame)
- m_frameBufferCache[index] = *frame;
- return !pngDecoder->failed() || setFailed();
+ return m_frameBufferCache[index].getStatus() == ImageFrame::FrameComplete;
}
bool ICOImageDecoder::processDirectory() {
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698