Bug 708825 - set mIdentity to null if compartment enter fails. r=bholley a=akeybl
authorAndrew McCreight <amccreight@mozilla.com>
Tue, 03 Apr 2012 14:59:43 -0700
changeset 81764 8772f3d527ac471cfff0b62761b748d8dcb41e5b
parent 81763 076f467733b45aa2e058a3d2318d2eb956b449b3
child 81765 d9b4240fa8873fd6d7ed2fa5d315dd85050f29c2
push id94
push useramccreight@mozilla.com
push dateTue, 03 Apr 2012 22:00:06 +0000
reviewersbholley, akeybl
bugs708825
milestone10.0.4esrpre
Bug 708825 - set mIdentity to null if compartment enter fails. r=bholley a=akeybl
js/xpconnect/src/XPCWrappedNative.cpp
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -724,17 +724,23 @@ XPCWrappedNative::Morph(XPCCallContext& 
         return NS_ERROR_FAILURE;
 
     NS_ADDREF(wrapper);
 
     NS_ASSERTION(!xpc::WrapperFactory::IsXrayWrapper(js::GetObjectParent(existingJSObject)),
                  "Xray wrapper being used to parent XPCWrappedNative?");
 
     JSAutoEnterCompartment ac;
-    if (!ac.enter(ccx, existingJSObject) || !wrapper->Init(ccx, existingJSObject)) {
+    if (!ac.enter(ccx, existingJSObject)) {
+        wrapper->mIdentity = nsnull;
+        NS_RELEASE(wrapper);
+        return NS_ERROR_FAILURE;
+    }
+
+    if (!wrapper->Init(ccx, existingJSObject)) {
         NS_RELEASE(wrapper);
         return NS_ERROR_FAILURE;
     }
 
     nsresult rv;
     if (Interface && !wrapper->FindTearOff(ccx, Interface, JS_FALSE, &rv)) {
         // Second reference will be released by the FlatJSObject's finalizer.
         wrapper->Release();