Bug 1472520 - Fix a crash when generating image decoder telemetry. r=tnikkel
authorAndrew Osmond <aosmond@mozilla.com>
Wed, 04 Jul 2018 08:50:02 -0400
changeset 425028 5019176ab037fe17b5eb38e6cbb08f562fc102c0
parent 425027 0903f7dc6c7f3d7f10fec403d2ebee470e887876
child 425029 db22593e5f457f0d4ddac095c5997a0ab3c03b08
push id34232
push userrgurzau@mozilla.com
push dateWed, 04 Jul 2018 16:30:38 +0000
treeherdermozilla-central@6c0fa9a675c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1472520
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1472520 - Fix a crash when generating image decoder telemetry. r=tnikkel It is possible for a decoder's iterator to be invalid in some error conditions, all related to the ICO decoder seeking behaviour. Since we assume that the iterator is always valid for the purposes of generating the decoder's telemetry data, a malformed ICO image could cause a crash. This patch removes the assumption that the iterator is valid, and ensures we don't add the decoder's data to telemetry if it is invalid.
image/Decoder.cpp
image/RasterImage.cpp
--- a/image/Decoder.cpp
+++ b/image/Decoder.cpp
@@ -272,18 +272,18 @@ Decoder::FinalStatus() const
                             ShouldReportError());
 }
 
 DecoderTelemetry
 Decoder::Telemetry() const
 {
   MOZ_ASSERT(mIterator);
   return DecoderTelemetry(SpeedHistogram(),
-                          mIterator->ByteCount(),
-                          mIterator->ChunkCount(),
+                          mIterator ? mIterator->ByteCount() : 0,
+                          mIterator ? mIterator->ChunkCount() : 0,
                           mDecodeTime);
 }
 
 nsresult
 Decoder::AllocateFrame(const gfx::IntSize& aOutputSize,
                        const gfx::IntRect& aFrameRect,
                        gfx::SurfaceFormat aFormat,
                        uint8_t aPaletteDepth,
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -1771,17 +1771,17 @@ RasterImage::NotifyDecodeComplete(const 
       Telemetry::Accumulate(Telemetry::IMAGE_DECODE_TIME,
                             int32_t(aTelemetry.mDecodeTime.ToMicroseconds()));
 
       if (mAnimationState) {
         Telemetry::Accumulate(Telemetry::IMAGE_ANIMATED_DECODE_TIME,
                               int32_t(aTelemetry.mDecodeTime.ToMicroseconds()));
       }
 
-      if (aTelemetry.mSpeedHistogram) {
+      if (aTelemetry.mSpeedHistogram && aTelemetry.mBytesDecoded) {
         Telemetry::Accumulate(*aTelemetry.mSpeedHistogram, aTelemetry.Speed());
       }
     }
   }
 
   // Only act on errors if we have no usable frames from the decoder.
   if (aStatus.mHadError &&
       (!mAnimationState || mAnimationState->KnownFrameCount() == 0)) {