Commit 292ac9aa authored by Guido Urdaneta's avatar Guido Urdaneta Committed by Commit Bot

Use copy of source map in MediaElementElementListener::UpdateSources()

Prior to this CL, this function iterated over a source map that could
be modified by a re-entrant call triggered by JS code.

Bug: 1105426
Change-Id: I47e49e4132cba98e12ee7c195720ac9ecc1f485b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2312703Reviewed-by: default avatarMarina Ciocea <marinaciocea@chromium.org>
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790894}
parent f716f326
...@@ -240,9 +240,14 @@ void MediaElementEventListener::UpdateSources(ExecutionContext* context) { ...@@ -240,9 +240,14 @@ void MediaElementEventListener::UpdateSources(ExecutionContext* context) {
for (auto track : media_stream_->getTracks()) for (auto track : media_stream_->getTracks())
sources_.insert(track->Component()->Source()); sources_.insert(track->Component()->Source());
// Handling of the ended event in JS triggered by DidStopMediaStreamSource()
// may cause a reentrant call to this function, which can modify |sources_|.
// Iterate over a copy of |sources_| to avoid invalidation of the iterator
// when a reentrant call occurs.
auto sources_copy = sources_;
if (!media_element_->currentSrc().IsEmpty() && if (!media_element_->currentSrc().IsEmpty() &&
!media_element_->IsMediaDataCorsSameOrigin()) { !media_element_->IsMediaDataCorsSameOrigin()) {
for (auto source : sources_) for (auto source : sources_copy)
DidStopMediaStreamSource(source.Get()); DidStopMediaStreamSource(source.Get());
} }
} }
......
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