diff options
author | nagarajan.n <nagarajan.n@samsung.com> | 2017-09-29 08:23:32 +0530 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-10-03 12:24:58 +0000 |
commit | dd7ffa5a557bcaa1daebd0f056a8f1bafb992d4d (patch) | |
tree | 1705c1bbe6ac9365135db63efac655ccabf974c1 /src/codec | |
parent | 0804b57e12a64cb20c3389b5d36d0af6ed2332c2 (diff) |
Handle the error input case in SkPngCodec decode function
This patch handles the error input case in SkPngCodec decode function
when there is error in input.
Bug: skia:None
Change-Id: I53b44f2411cef129b39e76e2cd6b8cd4c754b932
Reviewed-on: https://skia-review.googlesource.com/51860
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'src/codec')
-rw-r--r-- | src/codec/SkPngCodec.cpp | 25 | ||||
-rw-r--r-- | src/codec/SkPngCodec.h | 2 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp index cb215e1c6c..67995654a9 100644 --- a/src/codec/SkPngCodec.cpp +++ b/src/codec/SkPngCodec.cpp @@ -189,15 +189,15 @@ bool AutoCleanPng::decodeBounds() { return false; } -void SkPngCodec::processData() { +bool SkPngCodec::processData() { switch (setjmp(PNG_JMPBUF(fPng_ptr))) { case kPngError: // There was an error. Stop processing data. // FIXME: Do we need to discard png_ptr? - return; + return false;; case kStopDecoding: // We decoded all the lines we want. - return; + return true; case kSetJmpOkay: // Everything is okay. break; @@ -240,6 +240,8 @@ void SkPngCodec::processData() { break; } } + + return true; } static const SkColorType kXformSrcColorType = kRGBA_8888_SkColorType; @@ -526,7 +528,9 @@ private: fFirstRow = 0; fLastRow = height - 1; - this->processData(); + if (!this->processData()) { + return kErrorInInput; + } if (fRowsWrittenToOutput == height) { return SkCodec::kSuccess; @@ -561,7 +565,10 @@ private: const int sampleY = this->swizzler()->sampleY(); fRowsNeeded = get_scaled_dimension(fLastRow - fFirstRow + 1, sampleY); } - this->processData(); + + if (!this->processData()) { + return kErrorInInput; + } if (fRowsWrittenToOutput == fRowsNeeded) { return SkCodec::kSuccess; @@ -673,7 +680,9 @@ private: fLastRow = height - 1; fLinesDecoded = 0; - this->processData(); + if (!this->processData()) { + return kErrorInInput; + } png_bytep srcRow = fInterlaceBuffer.get(); // FIXME: When resuming, this may rewrite rows that did not change. @@ -705,7 +714,9 @@ private: } SkCodec::Result decode(int* rowsDecoded) override { - this->processData(); + if (this->processData() == false) { + return kErrorInInput; + } // Now apply Xforms on all the rows that were decoded. if (!fLinesDecoded) { diff --git a/src/codec/SkPngCodec.h b/src/codec/SkPngCodec.h index 8496705258..6848cfc74c 100644 --- a/src/codec/SkPngCodec.h +++ b/src/codec/SkPngCodec.h @@ -71,7 +71,7 @@ protected: * libpng will call any relevant callbacks installed. This will continue decoding * until it reaches the end of the file, or until a callback tells libpng to stop. */ - void processData(); + bool processData(); Result onStartIncrementalDecode(const SkImageInfo& dstInfo, void* pixels, size_t rowBytes, const SkCodec::Options&) override; |