aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkPngCodec.cpp
diff options
context:
space:
mode:
authorGravatar nagarajan.n <nagarajan.n@samsung.com>2017-09-29 08:23:32 +0530
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-10-03 12:24:58 +0000
commitdd7ffa5a557bcaa1daebd0f056a8f1bafb992d4d (patch)
tree1705c1bbe6ac9365135db63efac655ccabf974c1 /src/codec/SkPngCodec.cpp
parent0804b57e12a64cb20c3389b5d36d0af6ed2332c2 (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/SkPngCodec.cpp')
-rw-r--r--src/codec/SkPngCodec.cpp25
1 files changed, 18 insertions, 7 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) {