Fix MSAN - mark temporary memory as kNo_ZeroInitialized
authormsarett <msarett@google.com>
Mon, 22 Aug 2016 20:00:05 +0000 (13:00 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 22 Aug 2016 20:00:05 +0000 (13:00 -0700)
TBR=mtklein@google.com
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2261173004

Review-Url: https://codereview.chromium.org/2261173004

src/codec/SkPngCodec.cpp

index 8f7ab79bf1f099df265e4c3796425cfa5ea22d6c..0d73ad03f4793a985447c6e26dc5fd5453c1796d 100644 (file)
@@ -818,6 +818,7 @@ bool SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& opt
     // because the interlaced scanline decoder may need to rewind.
     fColorXform = nullptr;
     SkImageInfo swizzlerInfo = dstInfo;
+    Options swizzlerOptions = options;
     bool needsColorXform = needs_color_xform(dstInfo, this->getInfo());
     if (needsColorXform) {
         switch (dstInfo.colorType()) {
@@ -841,6 +842,12 @@ bool SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& opt
         if (!fColorXform && kRGBA_F16_SkColorType == dstInfo.colorType()) {
             return false;
         }
+
+        // When there is a color xform, we swizzle into temporary memory, which is not
+        // zero initialized.
+        // FIXME (msarett):
+        // Is this a problem?
+        swizzlerOptions.fZeroInitialized = kNo_ZeroInitialized;
     }
 
     if (SkEncodedInfo::kPalette_Color == this->getEncodedInfo().color()) {
@@ -855,7 +862,7 @@ bool SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& opt
     // Create the swizzler.  SkPngCodec retains ownership of the color table.
     const SkPMColor* colors = get_color_ptr(fColorTable.get());
     fSwizzler.reset(SkSwizzler::CreateSwizzler(this->getEncodedInfo(), colors, swizzlerInfo,
-                                               options));
+                                               swizzlerOptions));
     SkASSERT(fSwizzler);
     return true;
 }