Bug 705961 - Ensure nsDocument doesn't modify the external resource hashtable while enumerating it. r=bz
authorBill de Araujo <guimdearaujo@gmail.com>
Fri, 01 Feb 2013 16:09:00 +0000
changeset 120774 d0efae27e0138955dad49a9e2566d8c1f5988f58
parent 120773 83d6989fa8d8a45212abc4d193916911c99b6cae
child 120775 6a1cd615cefba7e4aa43664525bb120bd6e2ada1
push id24264
push userryanvm@gmail.com
push dateTue, 05 Feb 2013 00:26:09 +0000
treeherdermozilla-central@2360c3c46aca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs705961
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 705961 - Ensure nsDocument doesn't modify the external resource hashtable while enumerating it. r=bz
content/base/src/nsDocument.cpp
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -6729,33 +6729,38 @@ nsDocument::FlushPendingNotifications(mo
       mInFlush = true;
       shell->FlushPendingNotifications(aType);
       mInFlush = oldInFlush;
     }
   }
 }
 
 static bool
-Flush(nsIDocument* aDocument, void* aData)
-{
-  const mozFlushType* type = static_cast<const mozFlushType*>(aData);
-  aDocument->FlushPendingNotifications(*type);
+Copy(nsIDocument* aDocument, void* aData)
+{
+  nsTArray<nsCOMPtr<nsIDocument> >* resources =
+    static_cast<nsTArray<nsCOMPtr<nsIDocument> >* >(aData);
+  resources->AppendElement(aDocument);
   return true;
 }
 
 void
 nsDocument::FlushExternalResources(mozFlushType aType)
 {
   NS_ASSERTION(aType >= Flush_Style,
     "should only need to flush for style or higher in external resources");
-
   if (GetDisplayDocument()) {
     return;
   }
-  EnumerateExternalResources(Flush, &aType);
+  nsTArray<nsCOMPtr<nsIDocument> > resources;
+  EnumerateExternalResources(Copy, &resources);
+
+  for (uint32_t i = 0; i < resources.Length(); i++) {
+    resources[i]->FlushPendingNotifications(aType);
+  }
 }
 
 void
 nsDocument::SetXMLDeclaration(const PRUnichar *aVersion,
                               const PRUnichar *aEncoding,
                               const int32_t aStandalone)
 {
   if (!aVersion || *aVersion == '\0') {