aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkGifCodec.cpp
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2017-07-06 12:26:09 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-06 16:49:36 +0000
commit674a1848ae62277ea9a2d022b60aa1f17d306f17 (patch)
tree0f1b7396e4a7c3d2c561fd96969063e51062faaa /src/codec/SkGifCodec.cpp
parent005a970eb9d70e729cdebf0f79551577b112aa7b (diff)
Add SkCodec::Result indicating error in the data
Previously, SkGifCodec treated an error in the LZW data as incomplete, since we can still draw the partially decoded image. But a client doing incremental decodes needs to distinguish this from truly incomplete data. In the case of an error, the client should not attempt to provide more data and decode again. Add kErrorInInput, and return it when SkGifCodec sees a fatal error. Treat it the same as kIncompleteInput when it comes to filling and DM. Bug: skia:6825 Change-Id: Ic6ce3a62c0b065ed34dcd8006309e43272a3db9f Reviewed-on: https://skia-review.googlesource.com/21530 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Chris Blume <cblume@chromium.org>
Diffstat (limited to 'src/codec/SkGifCodec.cpp')
-rw-r--r--src/codec/SkGifCodec.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/codec/SkGifCodec.cpp b/src/codec/SkGifCodec.cpp
index eefe8986b7..89889d2555 100644
--- a/src/codec/SkGifCodec.cpp
+++ b/src/codec/SkGifCodec.cpp
@@ -407,20 +407,15 @@ SkCodec::Result SkGifCodec::decodeFrame(bool firstAttempt, const Options& opts,
return kSuccess;
}
- // Note: there is a difference between the following call to SkGifImageReader::decode
- // returning false and leaving frameDecoded false:
- // - If the method returns false, there was an error in the stream. We still treat this as
- // incomplete, since we have already decoded some rows.
- // - If frameDecoded is false, that just means that we do not have enough data. If more data
- // is supplied, we may be able to continue decoding this frame. We also treat this as
- // incomplete.
- // FIXME: Ensure that we do not attempt to continue decoding if the method returns false and
- // more data is supplied.
bool frameDecoded = false;
- if (!fReader->decode(frameIndex, &frameDecoded) || !frameDecoded) {
+ const bool fatalError = !fReader->decode(frameIndex, &frameDecoded);
+ if (fatalError || !frameDecoded) {
if (rowsDecoded) {
*rowsDecoded = fRowsDecoded;
}
+ if (fatalError) {
+ return kErrorInInput;
+ }
return kIncompleteInput;
}