Bug 1351553 - fix divide-by-zero. draft
authorJW Wang <jwwang@mozilla.com>
Wed, 29 Mar 2017 16:15:13 +0800
changeset 552933 4ca8fa49df7a0351c3f079c38bccf20104e1d8e8
parent 552827 8d504462c497bbb487a2237dcb73877796100197
child 621951 289ecb7f02b935e42b169f57955f8a2beb463d4a
push id51512
push userjwwang@mozilla.com
push dateWed, 29 Mar 2017 08:24:29 +0000
bugs1351553
milestone55.0a1
Bug 1351553 - fix divide-by-zero. MozReview-Commit-ID: BZVCVOOLx1L
dom/media/MediaDecoder.cpp
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1031,17 +1031,18 @@ MediaDecoder::GetStatistics()
 
 void
 MediaDecoder::ComputePlaybackRate()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mResource);
 
   int64_t length = mResource->GetLength();
-  if (!IsNaN(mDuration) && !mozilla::IsInfinite<double>(mDuration)
+  if (!mozilla::IsInfinite<double>(mDuration)
+      && mDuration > 0
       && length >= 0) {
     mPlaybackRateReliable = true;
     mPlaybackBytesPerSecond = length / mDuration;
     return;
   }
 
   bool reliable = false;
   mPlaybackBytesPerSecond = mPlaybackStatistics->GetRateAtLastStop(&reliable);