Bug 579782 - Deal with a null context when closing the window. r=jst
authorBlake Kaplan <mrbkap@gmail.com>
Wed, 21 Jul 2010 17:17:35 -0700
changeset 48112 bc650e77bc23783cfac1cac109568e521fa508a2
parent 48111 50ea31d46c0ee86ed555f19ff633ab9ccf222d3a
child 48113 ae3ea4a4320f46597086517d1b891bf3144a971c
push id14575
push usermrbkap@mozilla.com
push dateThu, 22 Jul 2010 23:53:11 +0000
treeherdermozilla-central@ae3ea4a4320f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs579782
milestone2.0b3pre
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 579782 - Deal with a null context when closing the window. r=jst
dom/base/nsGlobalWindow.cpp
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -2162,33 +2162,37 @@ nsGlobalWindow::SetDocShell(nsIDocShell*
       // Remember the document's principal.
       mDocumentPrincipal = mDoc->NodePrincipal();
 
       // Release our document reference
       mDocument = nsnull;
       mDoc = nsnull;
     }
 
-    mContext->ClearScope(mJSObject, PR_TRUE);
+    if (mContext) {
+      mContext->ClearScope(mJSObject, PR_TRUE);
+    }
 
     ClearControllers();
 
     mChromeEventHandler = nsnull; // force release now
 
     if (mArguments) { 
       // We got no new document after someone called
       // SetArguments(), drop our reference to the arguments.
       mArguments = nsnull;
       mArgumentsLast = nsnull;
       mArgumentsOrigin = nsnull;
     }
 
-    mContext->GC();
-    mContext->FinalizeContext();
-    mContext = nsnull;
+    if (mContext) {
+      mContext->GC();
+      mContext->FinalizeContext();
+      mContext = nsnull;
+    }
 
 #ifdef DEBUG
     nsCycleCollector_DEBUG_shouldBeFreed(mContext);
     nsCycleCollector_DEBUG_shouldBeFreed(static_cast<nsIScriptGlobalObject*>(this));
 #endif
   }
 
   mDocShell = aDocShell;        // Weak Reference