Bug 1322390 - Iterate over a copy of mOwnedDirectListeners when removing them, r=pehrsons
authorMichael Layzell <michael@thelayzells.com>
Wed, 07 Dec 2016 10:31:09 -1000
changeset 325469 9f61239c41a03f33936e696e487a263336cf78b3
parent 325468 8cc548682ae3f4fede10b12f12b8d7874297c9b4
child 325470 b57b890350b0e607b4d9b4ca266a761d20fae15e
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerspehrsons
bugs1322390
milestone53.0a1
Bug 1322390 - Iterate over a copy of mOwnedDirectListeners when removing them, r=pehrsons MozReview-Commit-ID: PCLCEiKTFO
dom/media/TrackUnionStream.cpp
--- a/dom/media/TrackUnionStream.cpp
+++ b/dom/media/TrackUnionStream.cpp
@@ -53,17 +53,19 @@ TrackUnionStream::TrackUnionStream() :
 
   void TrackUnionStream::RemoveInput(MediaInputPort* aPort)
   {
     STREAM_LOG(LogLevel::Debug, ("TrackUnionStream %p removing input %p", this, aPort));
     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);
-        for (auto listener : mTrackMap[i].mOwnedDirectListeners) {
+        nsTArray<RefPtr<DirectMediaStreamTrackListener>> listeners(
+          mTrackMap[i].mOwnedDirectListeners);
+        for (auto listener : listeners) {
           // Remove listeners while the entry still exists.
           RemoveDirectTrackListenerImpl(listener, mTrackMap[i].mOutputTrackID);
         }
         mTrackMap.RemoveElementAt(i);
       }
     }
     ProcessedMediaStream::RemoveInput(aPort);
   }