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
This commit is contained in:
yujieqin 2016-03-03 07:38:27 -08:00 committed by Commit bot
parent 99354b81c3
commit d0e0885d90

View File

@ -515,6 +515,11 @@ private:
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 @@ SkCodec::Result SkRawCodec::onGetPixels(const SkImageInfo& requestedInfo, void*
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;
}