Bug 830399. Add JSAutoCompartment in nsXMLHttpRequest::GetInterface. r=bz a=akeybl
authorAndrew McCreight <amccreight@mozilla.com>
Thu, 17 Jan 2013 16:30:41 -0800
changeset 127258 e700932a28bfe8ba1c93055e54433fd640c73b2a
parent 127257 03685ebd4b2bf46cc064affd3665db97c15fe714
child 127259 256a897249c7b803d928bd285643eb4b640c16a4
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, akeybl
bugs830399
milestone20.0a2
Bug 830399. Add JSAutoCompartment in nsXMLHttpRequest::GetInterface. r=bz a=akeybl
content/base/src/nsXMLHttpRequest.cpp
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -3866,17 +3866,19 @@ JS::Value
 nsXMLHttpRequest::GetInterface(JSContext* aCx, nsIJSID* aIID, ErrorResult& aRv)
 {
   const nsID* iid = aIID->GetID();
   nsCOMPtr<nsISupports> result;
   JS::Value v = JSVAL_NULL;
   aRv = GetInterface(*iid, getter_AddRefs(result));
   NS_ENSURE_FALSE(aRv.Failed(), JSVAL_NULL);
 
-  JSObject* global = JS_GetGlobalForObject(aCx, GetWrapper());
+  JSObject* wrapper = GetWrapper();
+  JSAutoCompartment ac(aCx, wrapper);
+  JSObject* global = JS_GetGlobalForObject(aCx, wrapper);
   aRv = nsContentUtils::WrapNative(aCx, global, result, iid, &v);
   return aRv.Failed() ? JSVAL_NULL : v;
 }
 
 nsXMLHttpRequestUpload*
 nsXMLHttpRequest::Upload()
 {
   if (!mUpload) {