diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 16f0aaf52bcb..59616b7b004a 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -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");