Verify the full size returned by PIEX
cherry-pick of d0e0885d90cecd43b717d89b565d9a713cffd90c in master
Original commit message below:
========================================================================
Verify the full size returned by PIEX
As the full size info is only optional, one needs to verify the values
before using them
BUG=b/27422694
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1757273002
Review URL: https://codereview.chromium.org/1757273002
NOTREECHECKS=true
NOTRY=true
NOPRESUBMIT=true
Review URL: https://codereview.chromium.org/1757353002
diff --git a/src/codec/SkRawCodec.cpp b/src/codec/SkRawCodec.cpp
index 9d0fb1c..524a438 100644
--- a/src/codec/SkRawCodec.cpp
+++ b/src/codec/SkRawCodec.cpp
@@ -515,6 +515,11 @@
if (::piex::IsRaw(&piexStream)
&& ::piex::GetPreviewImageData(&piexStream, &imageData) == ::piex::Error::kOk)
{
+ // Verify the size information, as it is only optional information for PIEX.
+ if (imageData.full_width == 0 || imageData.full_height == 0) {
+ return false;
+ }
+
dng_point cfaPatternSize(imageData.cfa_pattern_dim[1], imageData.cfa_pattern_dim[0]);
this->init(static_cast<int>(imageData.full_width),
static_cast<int>(imageData.full_height), cfaPatternSize);
@@ -670,7 +675,10 @@
SkISize SkRawCodec::onGetScaledDimensions(float desiredScale) const {
SkASSERT(desiredScale <= 1.f);
+
const SkISize dim = this->getInfo().dimensions();
+ SkASSERT(dim.fWidth != 0 && dim.fHeight != 0);
+
if (!fDngImage->isScalable()) {
return dim;
}