diff options
author | Leon Scroggins III <scroggo@google.com> | 2017-01-11 17:59:47 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-01-11 17:59:47 +0000 |
commit | ecbbc7d04216d558f52e2a57f8606176171b557b (patch) | |
tree | 907e587be1c4d2a2f6d02db1ff4191c675fad3e4 | |
parent | c37873eb428715fa9296957de24899124d8438d1 (diff) | |
parent | 20de35a0fd855c60b40a7d5d513bbe8e19fda49b (diff) | |
download | skia-ecbbc7d04216d558f52e2a57f8606176171b557b.tar.gz |
DO NOT MERGE Do not create an SkRawCodec with zero dimensions
am: 20de35a0fd
Change-Id: Ia7b3497eea0e8f5d8524515307905e73d40ab0cf
-rw-r--r-- | resources/empty_images/zero_height.tiff | bin | 0 -> 87460 bytes | |||
-rw-r--r-- | src/codec/SkRawCodec.cpp | 21 | ||||
-rw-r--r-- | tests/CodexTest.cpp | 3 |
3 files changed, 11 insertions, 13 deletions
diff --git a/resources/empty_images/zero_height.tiff b/resources/empty_images/zero_height.tiff Binary files differnew file mode 100644 index 0000000000..ea7a4777af --- /dev/null +++ b/resources/empty_images/zero_height.tiff diff --git a/src/codec/SkRawCodec.cpp b/src/codec/SkRawCodec.cpp index ab2c55d9aa..eea551e361 100644 --- a/src/codec/SkRawCodec.cpp +++ b/src/codec/SkRawCodec.cpp @@ -542,13 +542,15 @@ private: (header[0] == 0x4D && header[1] == 0x4D && header[2] == 0x00 && header[3] == 0x2A); } - void init(const int width, const int height, const dng_point& cfaPatternSize) { + bool init(const int width, const int height, const dng_point& cfaPatternSize) { fImageInfo = SkImageInfo::Make(width, height, kN32_SkColorType, kOpaque_SkAlphaType); // The DNG SDK scales only during demosaicing, so scaling is only possible when // a mosaic info is available. fIsScalable = cfaPatternSize.v != 0 && cfaPatternSize.h != 0; fIsXtransImage = fIsScalable ? (cfaPatternSize.v == 6 && cfaPatternSize.h == 6) : false; + + return width > 0 && height > 0; } bool initFromPiex() { @@ -558,15 +560,9 @@ 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); - return true; + return this->init(static_cast<int>(imageData.full_width), + static_cast<int>(imageData.full_height), cfaPatternSize); } return false; } @@ -594,10 +590,9 @@ private: if (fNegative->GetMosaicInfo() != nullptr) { cfaPatternSize = fNegative->GetMosaicInfo()->fCFAPatternSize; } - this->init(static_cast<int>(fNegative->DefaultCropSizeH().As_real64()), - static_cast<int>(fNegative->DefaultCropSizeV().As_real64()), - cfaPatternSize); - return true; + return this->init(static_cast<int>(fNegative->DefaultCropSizeH().As_real64()), + static_cast<int>(fNegative->DefaultCropSizeV().As_real64()), + cfaPatternSize); } catch (...) { return false; } diff --git a/tests/CodexTest.cpp b/tests/CodexTest.cpp index 8ce63029a6..7e6d950430 100644 --- a/tests/CodexTest.cpp +++ b/tests/CodexTest.cpp @@ -628,6 +628,9 @@ DEF_TEST(Codec_Empty, r) { test_invalid(r, "empty_images/zero-height.wbmp"); // This image is an ico with an embedded mask-bmp. This is illegal. test_invalid(r, "invalid_images/mask-bmp-ico.ico"); +#if defined(SK_CODEC_DECODES_RAW) && (!defined(_WIN32)) + test_invalid(r, "empty_images/zero_height.tiff"); +#endif } static void test_invalid_parameters(skiatest::Reporter* r, const char path[]) { |