Bug 1413702 - avoid dividing by zero. r?kinetik draft
authorAlfredo.Yang <ayang@mozilla.com>
Mon, 06 Nov 2017 17:26:09 +0800
changeset 693460 a6ce2d1c10b8e85dee89696ad244fc438d39af34
parent 693376 179dae92e4d794e7f45ad080ff01908c80691f31
child 739040 51d9a1aba46613eaae0f5a9c3a2b8e325772bb5b
push id87810
push userbmo:ayang@mozilla.com
push dateMon, 06 Nov 2017 09:27:36 +0000
reviewerskinetik
bugs1413702
milestone58.0a1
Bug 1413702 - avoid dividing by zero. r?kinetik MozReview-Commit-ID: 38ZdC9udcH1
media/libstagefright/binding/MoofParser.cpp
--- a/media/libstagefright/binding/MoofParser.cpp
+++ b/media/libstagefright/binding/MoofParser.cpp
@@ -442,17 +442,17 @@ Moof::Moof(Box& aBox, Trex& aTrex, Mvhd&
       int64_t presentationDuration =
         ctsOrder.LastElement()->mCompositionRange.end
         - ctsOrder[0]->mCompositionRange.start;
       auto decodeOffset = aMdhd.ToMicroseconds((int64_t)*aDecodeTime - aEdts.mMediaStart);
       auto offsetOffset = aMvhd.ToMicroseconds(aEdts.mEmptyOffset);
       int64_t endDecodeTime = decodeOffset.isOk() & offsetOffset.isOk() ?
                               decodeOffset.unwrap() + offsetOffset.unwrap() : 0;
       int64_t decodeDuration = endDecodeTime - mIndex[0].mDecodeTime;
-      double adjust = (double)decodeDuration / presentationDuration;
+      double adjust = !!presentationDuration ? (double)decodeDuration / presentationDuration : 0;
       int64_t dtsOffset = mIndex[0].mDecodeTime;
       int64_t compositionDuration = 0;
       // Adjust the dts, ensuring that the new adjusted dts will never be greater
       // than decodeTime (the next moof's decode start time).
       for (auto& sample : mIndex) {
         sample.mDecodeTime = dtsOffset + int64_t(compositionDuration * adjust);
         compositionDuration += sample.mCompositionRange.Length();
       }