Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Unified Diff: Source/core/dom/MutationObserver.cpp

Issue 1039523003: MutationObserver: add a check that iterating registration still exists in original set (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: comment Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/MutationObserver.cpp
diff --git a/Source/core/dom/MutationObserver.cpp b/Source/core/dom/MutationObserver.cpp
index 46905e3e15366b3b0507b493c7c416f052d30ba2..b90f533d01cdc4f83d053fc6c3b25d1af35500a4 100644
--- a/Source/core/dom/MutationObserver.cpp
+++ b/Source/core/dom/MutationObserver.cpp
@@ -156,8 +156,12 @@ void MutationObserver::disconnect()
m_records.clear();
InspectorInstrumentation::didClearAllMutationRecords(m_callback->executionContext(), this);
MutationObserverRegistrationSet registrations(m_registrations);
- for (auto& registration : registrations)
- registration->unregister();
+ for (auto& registration : registrations) {
+ // The registration may be already unregistered while iteration.
+ // Only call unregister if it is still in the original set.
+ if (m_registrations.contains(registration))
+ registration->unregister();
+ }
ASSERT(m_registrations.isEmpty());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698