Bug 1339566: Acquire kungFuDeathGrip a bit earlier, in some nsDocShell code. r=mccr8 a=jcristau
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 17 Feb 2017 11:07:08 -0800
changeset 376260 db2e6ff03ae1c57ebd4b4dae874d744bd1b8a41b
parent 376259 9a78c5da4fc8855bfe7c3d3234bd3c6e413b4517
child 376261 7351f4e27c493e488d4e233a323ad1a1a49df598
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8, jcristau
bugs1339566
milestone53.0a2
Bug 1339566: Acquire kungFuDeathGrip a bit earlier, in some nsDocShell code. r=mccr8 a=jcristau MozReview-Commit-ID: AXTQqwyJPmU
docshell/base/nsDocShell.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -7980,22 +7980,22 @@ nsDocShell::CreateAboutBlankContentViewe
      a theoretical possibility. We want to know about it and make it stop,
      and this sounds like a job for an assertion. */
   NS_ASSERTION(!mCreatingDocument,
                "infinite(?) loop creating document averted");
   if (mCreatingDocument) {
     return NS_ERROR_FAILURE;
   }
 
+  // mContentViewer->PermitUnload may release |this| docshell.
+  nsCOMPtr<nsIDocShell> kungFuDeathGrip(this);
+
   AutoRestore<bool> creatingDocument(mCreatingDocument);
   mCreatingDocument = true;
 
-  // mContentViewer->PermitUnload may release |this| docshell.
-  nsCOMPtr<nsIDocShell> kungFuDeathGrip(this);
-
   if (aPrincipal && !nsContentUtils::IsSystemPrincipal(aPrincipal) &&
       mItemType != typeChrome) {
     MOZ_ASSERT(ChromeUtils::IsOriginAttributesEqualIgnoringAddonId(
       aPrincipal->OriginAttributesRef(),
       mOriginAttributes));
   }
 
   // Make sure timing is created.  But first record whether we had it