REGRESSION (r252792?): 6 inspector/canvas tests crashing
https://bugs.webkit.org/show_bug.cgi?id=204542

Reviewed by Devin Rousso.

Copy the list of identifiers to a Vector before iterating over it
since m_identifierToInspectorCanvas could be mutated meanwhile.

* inspector/agents/InspectorCanvasAgent.cpp:
(WebCore::InspectorCanvasAgent::recordCanvasAction):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@252823 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index d1e41e0..ac31281 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,16 @@
+2019-11-22  Ryosuke Niwa  <rniwa@webkit.org>
+
+        REGRESSION (r252792?): 6 inspector/canvas tests crashing
+        https://bugs.webkit.org/show_bug.cgi?id=204542
+
+        Reviewed by Devin Rousso.
+
+        Copy the list of identifiers to a Vector before iterating over it
+        since m_identifierToInspectorCanvas could be mutated meanwhile.
+
+        * inspector/agents/InspectorCanvasAgent.cpp:
+        (WebCore::InspectorCanvasAgent::recordCanvasAction):
+
 2019-11-21  Ryosuke Niwa  <rniwa@webkit.org>
 
         Associate each microtask with a task group and remove ActiveDOMCallbackMicrotask
diff --git a/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp b/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp
index 53469dc..7568290 100644
--- a/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp
+++ b/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp
@@ -457,7 +457,8 @@
 
                 auto& canvasAgent = *weakThis;
 
-                for (auto& identifier : canvasAgent.m_recordingCanvasIdentifiers) {
+                auto identifiers = copyToVector(canvasAgent.m_recordingCanvasIdentifiers);
+                for (auto& identifier : identifiers) {
                     auto inspectorCanvas = canvasAgent.m_identifierToInspectorCanvas.get(identifier);
                     if (!inspectorCanvas)
                         continue;