Bug 631490. Fix compartment mismatch when dealing with certain types of global properties. r=mrbkap@gmail.com, a=blocker
authorJohnny Stenback <jst@mozilla.com>
Fri, 04 Feb 2011 09:55:21 -0800
changeset 62126 bb740aa9e48efd0003fbaed25f38aac72e5ecb53
parent 62125 622553a5c89dc7be9d73393e52c4d449ebc91dc7
child 62127 26d3a5196a5e8f99f11db92c2e9887972d01dfd8
push id18606
push userjst@mozilla.com
push dateTue, 08 Feb 2011 05:11:18 +0000
treeherdermozilla-central@bb740aa9e48e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap, blocker
bugs631490
milestone2.0b12pre
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 631490. Fix compartment mismatch when dealing with certain types of global properties. r=mrbkap@gmail.com, a=blocker
dom/base/nsDOMClassInfo.cpp
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -6528,29 +6528,25 @@ nsWindowSH::GlobalResolve(nsGlobalWindow
     nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
     nsCOMPtr<nsIScriptObjectOwner> owner(do_QueryInterface(native));
     if (owner) {
       nsIScriptContext *context = nsJSUtils::GetStaticScriptContext(cx, obj);
       NS_ENSURE_TRUE(context, NS_ERROR_UNEXPECTED);
 
       JSObject *prop_obj = nsnull;
       rv = owner->GetScriptObject(context, (void**)&prop_obj);
-      NS_ENSURE_TRUE(prop_obj, NS_ERROR_UNEXPECTED);
+      NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && prop_obj, NS_ERROR_UNEXPECTED);
 
       prop_val = OBJECT_TO_JSVAL(prop_obj);
     } else {
       nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi(do_QueryInterface(native));
 
       if (gpi) {
         rv = gpi->Init(aWin, &prop_val);
         NS_ENSURE_SUCCESS(rv, rv);
-
-        if (!JS_WrapValue(cx, &prop_val)) {
-          return NS_ERROR_UNEXPECTED;
-        }
       }
     }
 
     if (JSVAL_IS_PRIMITIVE(prop_val)) {
       JSObject *scope;
 
       if (aWin->IsOuterWindow()) {
         nsGlobalWindow *inner = aWin->GetCurrentInnerWindowInternal();
@@ -6562,16 +6558,20 @@ nsWindowSH::GlobalResolve(nsGlobalWindow
       }
 
       rv = WrapNative(cx, scope, native, PR_TRUE, &prop_val,
                       getter_AddRefs(holder));
     }
 
     NS_ENSURE_SUCCESS(rv, rv);
 
+    if (!JS_WrapValue(cx, &prop_val)) {
+      return NS_ERROR_UNEXPECTED;
+    }
+
     JSBool ok = ::JS_DefinePropertyById(cx, obj, id, prop_val, nsnull, nsnull,
                                         JSPROP_ENUMERATE);
 
     *did_resolve = PR_TRUE;
 
     return ok ? NS_OK : NS_ERROR_FAILURE;
   }