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

Unified Diff: Source/WebCore/dom/WebKitMutationObserver.cpp

Issue 9999033: Merge 113378 - Crash in MutationObservers due to an invalid HashSet iterator (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1084/
Patch Set: Created 8 years, 8 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 | « Source/WebCore/dom/WebKitMutationObserver.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/dom/WebKitMutationObserver.cpp
===================================================================
--- Source/WebCore/dom/WebKitMutationObserver.cpp (revision 113746)
+++ Source/WebCore/dom/WebKitMutationObserver.cpp (working copy)
@@ -135,17 +135,30 @@
activeMutationObservers().add(this);
}
+void WebKitMutationObserver::setHasTransientRegistration()
+{
+ ASSERT(isMainThread());
+ activeMutationObservers().add(this);
+}
+
void WebKitMutationObserver::deliver()
{
+ // Calling clearTransientRegistrations() can modify m_registrations, so it's necessary
+ // to make a copy of the transient registrations before operating on them.
+ Vector<MutationObserverRegistration*, 1> transientRegistrations;
+ for (HashSet<MutationObserverRegistration*>::iterator iter = m_registrations.begin(); iter != m_registrations.end(); ++iter) {
+ if ((*iter)->hasTransientRegistrations())
+ transientRegistrations.append(*iter);
+ }
+ for (size_t i = 0; i < transientRegistrations.size(); ++i)
+ transientRegistrations[i]->clearTransientRegistrations();
+
if (m_records.isEmpty())
return;
MutationRecordArray records;
records.swap(m_records);
- for (HashSet<MutationObserverRegistration*>::iterator iter = m_registrations.begin(); iter != m_registrations.end(); ++iter)
- (*iter)->clearTransientRegistrations();
-
m_callback->handleEvent(&records, this);
}
« no previous file with comments | « Source/WebCore/dom/WebKitMutationObserver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698