Bug 1322390 - Iterate over a copy of mOwnedDirectListeners when removing them, r=pehrsons a=gchang FIREFOX_51_0b7_BUILD1 FIREFOX_51_0b7_RELEASE
authorMichael Layzell <michael@thelayzells.com>
Wed, 07 Dec 2016 10:31:09 -1000
changeset 359080 829fcc7f60f04dffff4d29b007ef8015a1cd2c99
parent 359079 563aed975b1f99e324c8f0cab7619b18bbb07af7
child 359081 e5997b747aed3e731cfac25c14ecd889cdba40ef
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons, gchang
bugs1322390
milestone51.0
Bug 1322390 - Iterate over a copy of mOwnedDirectListeners when removing them, r=pehrsons a=gchang 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);
   }