Index: third_party/WebKit/Source/platform/mediastream/MediaStreamSource.cpp |
diff --git a/third_party/WebKit/Source/platform/mediastream/MediaStreamSource.cpp b/third_party/WebKit/Source/platform/mediastream/MediaStreamSource.cpp |
index 5819964562478268e9b9749276a3aee6f48efd36..62d5a02a47bc9fc08de87b58109c99fc945b0fd0 100644 |
--- a/third_party/WebKit/Source/platform/mediastream/MediaStreamSource.cpp |
+++ b/third_party/WebKit/Source/platform/mediastream/MediaStreamSource.cpp |
@@ -53,8 +53,13 @@ void MediaStreamSource::setReadyState(ReadyState readyState) |
{ |
if (m_readyState != ReadyStateEnded && m_readyState != readyState) { |
m_readyState = readyState; |
- for (auto i = m_observers.begin(); i != m_observers.end(); ++i) |
- (*i)->sourceChangedState(); |
+ |
+ // Observers may dispatch events which create and add new Observers; |
+ // take a snapshot so as to safely iterate. |
+ HeapVector<Member<Observer>> observers; |
+ copyToVector(m_observers, observers); |
+ for (auto observer : observers) |
+ observer->sourceChangedState(); |
} |
} |