Bug 1071003 - Fix null crash in XULDocument::ExecuteScript. r=smaug, a=sledru
authorBill McCloskey <wmccloskey@mozilla.com>
Thu, 25 Sep 2014 15:19:13 -0700
changeset 216857 b57f0af03f78
parent 216856 cf8866bd741f
child 216858 2b061899d368
push id3942
push userryanvm@gmail.com
push date2014-09-26 13:41 +0000
treeherdermozilla-beta@2b061899d368 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, sledru
bugs1071003
milestone33.0
Bug 1071003 - Fix null crash in XULDocument::ExecuteScript. r=smaug, a=sledru
content/xul/document/src/XULDocument.cpp
--- a/content/xul/document/src/XULDocument.cpp
+++ b/content/xul/document/src/XULDocument.cpp
@@ -3695,17 +3695,17 @@ XULDocument::ExecuteScript(nsIScriptCont
     // Execute the precompiled script with the given version
     nsAutoMicroTask mt;
     JSContext *cx = aContext->GetNativeContext();
     AutoCxPusher pusher(cx);
     JS::Rooted<JSObject*> baseGlobal(cx, mScriptGlobalObject->GetGlobalJSObject());
     NS_ENSURE_TRUE(baseGlobal, NS_ERROR_FAILURE);
     NS_ENSURE_TRUE(nsContentUtils::GetSecurityManager()->ScriptAllowed(baseGlobal), NS_OK);
 
-    JSAddonId *addonId = MapURIToAddonID(mCurrentPrototype->GetURI());
+    JSAddonId *addonId = mCurrentPrototype ? MapURIToAddonID(mCurrentPrototype->GetURI()) : nullptr;
     JS::Rooted<JSObject*> global(cx, xpc::GetAddonScope(cx, baseGlobal, addonId));
     NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
 
     JS::ExposeObjectToActiveJS(global);
     xpc_UnmarkGrayScript(aScriptObject);
     JSAutoCompartment ac(cx, global);
 
     // The script is in the compilation scope. Clone it into the target scope