Bug 605696 - Refuse to create location objects without an outer window. r=jst
authorBlake Kaplan <mrbkap@gmail.com>
Mon, 25 Oct 2010 12:13:36 -0700
changeset 56590 85fb4bc01a71
parent 56589 0e22005f6e4f
child 56591 9a1a2c464ac2
push id16602
push userrsayre@mozilla.com
push date2010-10-27 01:10 +0000
treeherdermozilla-central@7b83033bb6f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs605696
milestone2.0b8pre
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 605696 - Refuse to create location objects without an outer window. r=jst
dom/base/nsDOMClassInfo.cpp
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -7090,25 +7090,23 @@ nsLocationSH::PreCreate(nsISupports *nat
   nsLocation *loc = (nsLocation *)safeLoc.get();
   nsIDocShell *ds = loc->GetDocShell();
   if (!ds) {
     NS_WARNING("Refusing to create a location in the wrong scope");
     return NS_ERROR_UNEXPECTED;
   }
 
   nsCOMPtr<nsIScriptGlobalObject> sgo = do_GetInterface(ds);
-
-  if (sgo) {
-    JSObject *global = sgo->GetGlobalJSObject();
-
-    if (global) {
-      *parentObj = global;
-    }
-  }
-
+  if (!sgo) {
+    NS_WARNING("Refusing to create a location in the wrong scope because the "
+	       "docshell is being destroyed");
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  *parentObj = sgo->GetGlobalJSObject();
   return NS_OK;
 }
 
 // DOM Navigator helper
 nsresult
 nsNavigatorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
                          JSObject *globalObj, JSObject **parentObj)
 {