Bug 1097823 - Followup to avoid null-derefing when promises have already been rejected during shutdown. rpending=cpearce

This commit is contained in:
Bobby Holley 2014-12-07 15:08:47 -08:00
parent b007d59daf
commit eab5796fe5
2 changed files with 13 additions and 2 deletions

View File

@ -315,6 +315,9 @@ private:
bool mAudioDiscontinuity;
bool mVideoDiscontinuity;
bool mShutdown;
public:
bool IsShutdown() { return mShutdown; }
};
// Interface that callers to MediaDecoderReader::Request{Audio,Video}Data()

View File

@ -170,7 +170,11 @@ MediaSourceReader::OnAudioNotDecoded(NotDecodedReason aReason)
{
MSE_DEBUG("MediaSourceReader(%p)::OnAudioNotDecoded aReason=%u IsEnded: %d", this, aReason, IsEnded());
if (aReason == DECODE_ERROR || aReason == CANCELED) {
mAudioPromise.Reject(aReason, __func__);
if (!mAudioPromise.IsEmpty()) {
mAudioPromise.Reject(aReason, __func__);
} else {
MOZ_ASSERT(IsShutdown(), "This only happens when shutdown clears the promise");
}
return;
}
@ -260,7 +264,11 @@ MediaSourceReader::OnVideoNotDecoded(NotDecodedReason aReason)
{
MSE_DEBUG("MediaSourceReader(%p)::OnVideoNotDecoded aReason=%u IsEnded: %d", this, aReason, IsEnded());
if (aReason == DECODE_ERROR || aReason == CANCELED) {
mVideoPromise.Reject(aReason, __func__);
if (!mVideoPromise.IsEmpty()) {
mVideoPromise.Reject(aReason, __func__);
} else {
MOZ_ASSERT(IsShutdown(), "This only happens when shutdown clears the promise");
}
return;
}