Bug 1332845 - Remove direct listeners before ending track in TrackUnionStream. r=jesup

There was a race where ending the track before removing the direct listener here,
allowed the source to append more data (notifying the direct listener)
after the consumer had been notified of the ending track.

MozReview-Commit-ID: E08UeMNQhGx

--HG--
extra : rebase_source : 740c4fde40b9e19974922cd893618032c683493d
This commit is contained in:
Andreas Pehrson 2017-04-07 17:35:26 +02:00
parent 5835686871
commit 9c513ae0c5

View File

@ -57,13 +57,13 @@ TrackUnionStream::TrackUnionStream(AbstractThread* aMainThread) :
for (int32_t i = mTrackMap.Length() - 1; i >= 0; --i) {
if (mTrackMap[i].mInputPort == aPort) {
STREAM_LOG(LogLevel::Debug, ("TrackUnionStream %p removing trackmap entry %d", this, i));
EndTrack(i);
nsTArray<RefPtr<DirectMediaStreamTrackListener>> listeners(
mTrackMap[i].mOwnedDirectListeners);
for (auto listener : listeners) {
// Remove listeners while the entry still exists.
RemoveDirectTrackListenerImpl(listener, mTrackMap[i].mOutputTrackID);
}
EndTrack(i);
mTrackMap.RemoveElementAt(i);
}
}