From 5a9ff8849df1f39a8cd3f543ee5d9bce694cf442 Mon Sep 17 00:00:00 2001 From: JW Wang Date: Tue, 19 Dec 2017 14:56:08 +0800 Subject: [PATCH] Bug 1404441 - return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR if MediaData::AdjustForStartTime() results in an invalid mTime. r=jya MozReview-Commit-ID: 44VgbrknYbi --HG-- extra : rebase_source : 9bfbad053a955d7fb18f12a2f6cc6d3b43ee739d --- dom/media/ReaderProxy.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/dom/media/ReaderProxy.cpp b/dom/media/ReaderProxy.cpp index c462ee426712..f3ef73d130f6 100644 --- a/dom/media/ReaderProxy.cpp +++ b/dom/media/ReaderProxy.cpp @@ -62,8 +62,12 @@ ReaderProxy::OnAudioDataRequestCompleted(RefPtr aAudio) int64_t offset = StartTime().ToMicroseconds() - mLoopingOffset.ToMicroseconds(); aAudio->AdjustForStartTime(offset); - mLastAudioEndTime = aAudio->mTime; - return AudioDataPromise::CreateAndResolve(aAudio.forget(), __func__); + if (aAudio->mTime.IsValid()) { + mLastAudioEndTime = aAudio->mTime; + return AudioDataPromise::CreateAndResolve(aAudio.forget(), __func__); + } + return AudioDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_OVERFLOW_ERR, + __func__); } RefPtr @@ -149,8 +153,11 @@ ReaderProxy::RequestVideoData(const media::TimeUnit& aTimeThreshold) __func__, [startTime](RefPtr aVideo) { aVideo->AdjustForStartTime(startTime); - return VideoDataPromise::CreateAndResolve(aVideo.forget(), - __func__); + return aVideo->mTime.IsValid() + ? VideoDataPromise::CreateAndResolve(aVideo.forget(), + __func__) + : VideoDataPromise::CreateAndReject( + NS_ERROR_DOM_MEDIA_OVERFLOW_ERR, __func__); }, [](const MediaResult& aError) { return VideoDataPromise::CreateAndReject(aError, __func__);