Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1022773 - Return value rooting for XPConnect, r=bholley
Browse files Browse the repository at this point in the history
  • Loading branch information
hotsphink committed Jun 25, 2014
1 parent 7fb8682 commit 3033608
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions js/xpconnect/src/XPCComponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3174,8 +3174,8 @@ nsXPCComponents_Utils::GetComponentsForScope(HandleValue vscope, JSContext *cx,
return NS_ERROR_INVALID_ARG;
JSObject *scopeObj = js::UncheckedUnwrap(&vscope.toObject());
XPCWrappedNativeScope *scope = GetObjectScope(scopeObj);
RootedObject components(cx, scope->GetComponentsJSObject());
if (!components)
RootedObject components(cx);
if (!scope->GetComponentsJSObject(&components))
return NS_ERROR_FAILURE;
if (!JS_WrapObject(cx, &components))
return NS_ERROR_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/src/XPCJSRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ bool
IsInAddonScope(JSObject *obj)
{
// We always eagerly create compartment privates for addon scopes.
XPCWrappedNativeScope *scope = GetObjectScope(obj);
XPCWrappedNativeScope *scope = MaybeGetObjectScope(obj);
return scope && scope->IsAddonScope();
}

Expand Down
22 changes: 11 additions & 11 deletions js/xpconnect/src/XPCWrappedNativeScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ XPCWrappedNativeScope::IsDyingScope(XPCWrappedNativeScope *scope)
return false;
}

JSObject*
XPCWrappedNativeScope::GetComponentsJSObject()
bool
XPCWrappedNativeScope::GetComponentsJSObject(JS::MutableHandleObject obj)
{
AutoJSContext cx;
if (!mComponents) {
Expand All @@ -145,17 +145,17 @@ XPCWrappedNativeScope::GetComponentsJSObject()
nullptr, nullptr, false,
nullptr);
if (NS_WARN_IF(!ok))
return nullptr;
return false;

if (NS_WARN_IF(!val.isObject()))
return nullptr;
return false;

// The call to wrap() here is necessary even though the object is same-
// compartment, because it applies our security wrapper.
JS::RootedObject obj(cx, &val.toObject());
if (NS_WARN_IF(!JS_WrapObject(cx, &obj)))
return nullptr;
return obj;
obj.set(&val.toObject());
if (NS_WARN_IF(!JS_WrapObject(cx, obj)))
return false;
return true;
}

void
Expand All @@ -174,8 +174,8 @@ XPCWrappedNativeScope::ForcePrivilegedComponents()
bool
XPCWrappedNativeScope::AttachComponentsObject(JSContext* aCx)
{
RootedObject components(aCx, GetComponentsJSObject());
if (!components)
RootedObject components(aCx);
if (!GetComponentsJSObject(&components))
return false;

RootedObject global(aCx, GetGlobalJSObject());
Expand Down Expand Up @@ -697,7 +697,7 @@ XPCWrappedNativeScope::RemoveWrappedNativeProtos()
}

JSObject *
XPCWrappedNativeScope::GetExpandoChain(JSObject *target)
XPCWrappedNativeScope::GetExpandoChain(HandleObject target)
{
MOZ_ASSERT(GetObjectScope(target) == this);
if (!mXrayExpandos.initialized())
Expand Down
6 changes: 3 additions & 3 deletions js/xpconnect/src/xpcprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -985,8 +985,8 @@ class XPCWrappedNativeScope : public PRCList
bool AttachComponentsObject(JSContext *aCx);

// Returns the JS object reflection of the Components object.
JSObject*
GetComponentsJSObject();
bool
GetComponentsJSObject(JS::MutableHandleObject obj);

JSObject*
GetGlobalJSObject() const {
Expand All @@ -1004,7 +1004,7 @@ class XPCWrappedNativeScope : public PRCList
}

JSObject*
GetExpandoChain(JSObject *target);
GetExpandoChain(JS::HandleObject target);

bool
SetExpandoChain(JSContext *cx, JS::HandleObject target, JS::HandleObject chain);
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/wrappers/XrayWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class XrayTraits
JSObject* ensureHolder(JSContext *cx, HandleObject wrapper);
virtual JSObject* createHolder(JSContext *cx, JSObject *wrapper) = 0;

JSObject* getExpandoChain(JSObject *obj) {
JSObject* getExpandoChain(HandleObject obj) {
return GetObjectScope(obj)->GetExpandoChain(obj);
}

Expand Down

0 comments on commit 3033608

Please sign in to comment.