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

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

Issue 25422003: Ignore unsupported disposal methods when decoding GIF (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add test 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/GIFImageReader.cpp
diff --git a/Source/core/platform/image-decoders/gif/GIFImageReader.cpp b/Source/core/platform/image-decoders/gif/GIFImageReader.cpp
index 7716cedef363aebbee4eca7cfb9af0389a219161..bf18bea6229c14235b8fe8dda21906dea097b8cd 100644
--- a/Source/core/platform/image-decoders/gif/GIFImageReader.cpp
+++ b/Source/core/platform/image-decoders/gif/GIFImageReader.cpp
@@ -556,11 +556,13 @@ bool GIFImageReader::parseData(size_t dataPosition, size_t len, GIFImageDecoder:
// NOTE: This relies on the values in the FrameDisposalMethod enum
// matching those in the GIF spec!
int disposalMethod = ((*currentComponent) >> 2) & 0x7;
- currentFrame->setDisposalMethod(static_cast<WebCore::ImageFrame::DisposalMethod>(disposalMethod));
- // Some specs say that disposal method 3 is "overwrite previous", others that setting
- // the third bit of the field (i.e. method 4) is. We map both to the same value.
- if (disposalMethod == 4)
+ if (disposalMethod < 4) {
+ currentFrame->setDisposalMethod(static_cast<WebCore::ImageFrame::DisposalMethod>(disposalMethod));
+ } else if (disposalMethod == 4) {
+ // Some specs say that disposal method 3 is "overwrite previous", others that setting
+ // the third bit of the field (i.e. method 4) is. We map both to the same value.
currentFrame->setDisposalMethod(WebCore::ImageFrame::DisposeOverwritePrevious);
+ }
currentFrame->setDelayTime(GETINT16(currentComponent + 1) * 10);
GETN(1, GIFConsumeBlock);
break;
« no previous file with comments | « Source/core/platform/image-decoders/gif/GIFImageDecoderTest.cpp ('k') | Source/web/tests/data/invalid-disposal-method.gif » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698