Bug 1046534 - Call DropDocumentReference on a document's CSSLoader before we unlink it. r=dbaron a=sylvestre
authorCameron McCormack <cam@mcc.id.au>
Mon, 04 Aug 2014 07:24:36 +1000
changeset 229310 cff9d78d94253bd5678395731d64b4584f6e3af9
parent 229309 fabfefaa8950002a53121fba1ab2edc7eefa9644
child 229311 ae5bc80c1b9e4e1c737d61f246a00949282bdae3
push id6
push userryanvm@gmail.com
push dateMon, 12 Jan 2015 22:04:06 +0000
treeherdermozilla-b2g37_v2_2@895c8fc7b734 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron, sylvestre
bugs1046534
milestone33.0a2
Bug 1046534 - Call DropDocumentReference on a document's CSSLoader before we unlink it. r=dbaron a=sylvestre
content/base/src/nsDocument.cpp
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -1704,17 +1704,17 @@ nsDocument::~nsDocument()
     UnsetFlags(NODE_HAS_LISTENERMANAGER);
   }
 
   if (mScriptLoader) {
     mScriptLoader->DropDocumentReference();
   }
 
   if (mCSSLoader) {
-    // Could be null here if Init() failed
+    // Could be null here if Init() failed or if we have been unlinked.
     mCSSLoader->DropDocumentReference();
   }
 
   if (mStyleImageLoader) {
     mStyleImageLoader->DropDocumentReference();
   }
 
   delete mHeaderData;
@@ -2080,17 +2080,20 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
   tmp->mExpandoAndGeneration.Unlink();
 
   if (tmp->mAnimationController) {
     tmp->mAnimationController->Unlink();
   }
 
   tmp->mPendingTitleChangeEvent.Revoke();
 
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mCSSLoader)
+  if (tmp->mCSSLoader) {
+    tmp->mCSSLoader->DropDocumentReference();
+    NS_IMPL_CYCLE_COLLECTION_UNLINK(mCSSLoader)
+  }
 
   for (uint32_t i = 0; i < tmp->mHostObjectURIs.Length(); ++i) {
     nsHostObjectProtocolHandler::RemoveDataEntry(tmp->mHostObjectURIs[i]);
   }
 
   tmp->mInUnlinkOrDeletion = false;
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END