Do not create an SkRawCodec with zero dimensions

Add a test

BUG=skia:3534
BUG=b/33300701

Change-Id: Ifb3a824a36998c5e626c4ad58466845f49d18ebf
Reviewed-on: https://skia-review.googlesource.com/5568
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
diff --git a/src/codec/SkRawCodec.cpp b/src/codec/SkRawCodec.cpp
index dd86b62..843ccf0 100644
--- a/src/codec/SkRawCodec.cpp
+++ b/src/codec/SkRawCodec.cpp
@@ -553,7 +553,7 @@
         return 0x2A == get_endian_short(header + 2, littleEndian);
     }
 
-    void init(int width, int height, const dng_point& cfaPatternSize) {
+    bool init(int width, int height, const dng_point& cfaPatternSize) {
         fWidth = width;
         fHeight = height;
 
@@ -561,6 +561,8 @@
         // 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() {
@@ -570,15 +572,9 @@
         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;
     }
@@ -606,10 +602,9 @@
             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;
         }