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.
This commit is contained in:
Andrew Osmond 2018-07-04 08:50:02 -04:00
parent 3ffc5f5666
commit d588cc7135
2 changed files with 3 additions and 3 deletions

View file

@ -277,8 +277,8 @@ Decoder::Telemetry() const
{
MOZ_ASSERT(mIterator);
return DecoderTelemetry(SpeedHistogram(),
mIterator->ByteCount(),
mIterator->ChunkCount(),
mIterator ? mIterator->ByteCount() : 0,
mIterator ? mIterator->ChunkCount() : 0,
mDecodeTime);
}

View file

@ -1776,7 +1776,7 @@ RasterImage::NotifyDecodeComplete(const DecoderFinalStatus& aStatus,
int32_t(aTelemetry.mDecodeTime.ToMicroseconds()));
}
if (aTelemetry.mSpeedHistogram) {
if (aTelemetry.mSpeedHistogram && aTelemetry.mBytesDecoded) {
Telemetry::Accumulate(*aTelemetry.mSpeedHistogram, aTelemetry.Speed());
}
}