Bug 627943 - Bad ordering of exception save/wrap/restore, r=gal
authorSteve Fink <sfink@mozilla.com>
Fri, 21 Jan 2011 17:32:00 -0800
changeset 61426 fc8ec5cca4a2f0ae9ed5a18ec92516906f3dd207
parent 61425 066a856dc43f965f066b5ae0636b72ca5335bea4
child 61427 2089bf870890d746410c2a747c7889a3acc08a2b
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersgal
bugs627943
milestone2.0b10pre
Bug 627943 - Bad ordering of exception save/wrap/restore, r=gal
js/src/xpconnect/src/xpcwrappedjsclass.cpp
--- a/js/src/xpconnect/src/xpcwrappedjsclass.cpp
+++ b/js/src/xpconnect/src/xpcwrappedjsclass.cpp
@@ -1300,23 +1300,24 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
         cx = ccx.GetJSContext();
     }
     else
     {
         xpcc = nsnull;
         cx = nsnull;
     }
 
+    js::AutoValueVector args(cx);
+    /* This must come before AutoScriptEvaluate */
+    JSAutoEnterCompartment ac;
     AutoScriptEvaluate scriptEval(cx);
-    js::AutoValueVector args(cx);
     ContextPrincipalGuard principalGuard(ccx);
 
     obj = thisObj = wrapper->GetJSObject();
 
-    JSAutoEnterCompartment ac;
     if (!ac.enter(ccx, obj))
         goto pre_call_clean_up;
 
     // XXX ASSUMES that retval is last arg. The xpidl compiler ensures this.
     paramCount = info->num_args;
     argc = paramCount -
         (paramCount && XPT_PD_IS_RETVAL(info->params[paramCount-1].flags) ? 1 : 0);