Bug 940639 - Fix rooting hazard in nsXPCComponents_Utils::(Un)blockScriptForGlobal() r=bholley

This commit is contained in:
Jon Coppeard 2013-11-20 15:37:30 +00:00
parent e37996118d
commit 4d65d888cb

View File

@ -3381,8 +3381,8 @@ nsXPCComponents_Utils::BlockScriptForGlobal(const JS::Value &globalArg,
JSContext *cx)
{
NS_ENSURE_TRUE(globalArg.isObject(), NS_ERROR_INVALID_ARG);
JSObject *global = UncheckedUnwrap(&globalArg.toObject(),
/* stopAtOuter = */ false);
RootedObject global(cx, UncheckedUnwrap(&globalArg.toObject(),
/* stopAtOuter = */ false));
NS_ENSURE_TRUE(JS_IsGlobalObject(global), NS_ERROR_INVALID_ARG);
if (nsContentUtils::IsSystemPrincipal(GetObjectPrincipal(global))) {
JS_ReportError(cx, "Script may not be disabled for system globals");
@ -3397,8 +3397,8 @@ nsXPCComponents_Utils::UnblockScriptForGlobal(const JS::Value &globalArg,
JSContext *cx)
{
NS_ENSURE_TRUE(globalArg.isObject(), NS_ERROR_INVALID_ARG);
JSObject *global = UncheckedUnwrap(&globalArg.toObject(),
/* stopAtOuter = */ false);
RootedObject global(cx, UncheckedUnwrap(&globalArg.toObject(),
/* stopAtOuter = */ false));
NS_ENSURE_TRUE(JS_IsGlobalObject(global), NS_ERROR_INVALID_ARG);
if (nsContentUtils::IsSystemPrincipal(GetObjectPrincipal(global))) {
JS_ReportError(cx, "Script may not be disabled for system globals");