Bug 1453127 - Do not use iterators in MediaStreamTrack when removing listeners. r=pehrsons

--HG--
extra : rebase_source : 41c5d93b54c6dc062daa05a2644d4a194400dd1e
extra : amend_source : c53c4f75e4b813104122d22da29f97919f9d62d3
This commit is contained in:
Bryce Van Dyk 2018-04-18 15:30:57 -04:00
Родитель e6081ca579
Коммит 855803da5c
1 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -166,11 +166,15 @@ MediaStreamTrack::Destroy()
mPrincipalHandleListener->Forget();
mPrincipalHandleListener = nullptr;
}
for (auto l : mTrackListeners) {
RemoveListener(l);
// Remove all listeners -- avoid iterating over the list we're removing from
const nsTArray<RefPtr<MediaStreamTrackListener>> trackListeners(mTrackListeners);
for (auto listener : trackListeners) {
RemoveListener(listener);
}
for (auto l : mDirectTrackListeners) {
RemoveDirectListener(l);
// Do the same as above for direct listeners
const nsTArray<RefPtr<DirectMediaStreamTrackListener>> directTrackListeners(mDirectTrackListeners);
for (auto listener : directTrackListeners) {
RemoveDirectListener(listener);
}
}