Commit 4e3687fc authored by Thomas Guilbert's avatar Thomas Guilbert Committed by Commit Bot

Copy sinks before ReadyState change notification

MediaStreamVideoSinks may disconnect from a MediaStreamVideoTrack in
response to a OnReadyStateChanged() nofitication. This can lead to an
invalid iterator if the sinks disconnect synchronously.

This CL fixes the issue by iterating over a copy of sinks instead.

Bug: 1143213
Change-Id: I71fc43696d6b239f0bc4668b85474dc713e674b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2505552
Auto-Submit: Thomas Guilbert <tguilbert@chromium.org>
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822022}
parent a57118f4
......@@ -682,9 +682,16 @@ void MediaStreamVideoTrack::GetSettings(
void MediaStreamVideoTrack::OnReadyStateChanged(
WebMediaStreamSource::ReadyState state) {
DCHECK_CALLED_ON_VALID_THREAD(main_render_thread_checker_);
for (auto* sink : sinks_)
// Copy the vectors first, since sinks might DisconnectFromTrack() and
// invalidate iterators.
Vector<WebMediaStreamSink*> sinks_copy(sinks_);
for (auto* sink : sinks_copy)
sink->OnReadyStateChanged(state);
for (auto* encoded_sink : encoded_sinks_)
Vector<WebMediaStreamSink*> encoded_sinks_copy(encoded_sinks_);
for (auto* encoded_sink : encoded_sinks_copy)
encoded_sink->OnReadyStateChanged(state);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment