Bug 1472520 - Fix a crash when generating image decoder telemetry. r=tnikkel a=lizzard
authorAndrew Osmond <aosmond@mozilla.com>
Wed, 04 Jul 2018 08:50:02 -0400
changeset 477852 ad56b08003a84f5bc1783cf38b760c41d9b915da
parent 477851 5db3df3d5a433545830b6199ba28d28c93ef5d34
child 477853 ab4de937c2d276d352627bbcb43eace6f3610c21
push id9445
push userarchaeopteryx@coole-files.de
push dateSat, 07 Jul 2018 21:43:02 +0000
treeherdermozilla-beta@0a939a1cd7f9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel, lizzard
bugs1472520
milestone62.0
Bug 1472520 - Fix a crash when generating image decoder telemetry. r=tnikkel a=lizzard 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)) {