Commit 639c1461 authored by jst@mozilla.org's avatar jst@mozilla.org
Browse files

Fixing bug 434673. Fix GC safety issue when calling through XPCWrapper into an...

Fixing bug 434673. Fix GC safety issue when calling through XPCWrapper into an IDL defined function. r+sr=brendan@mozilla.org, a=shaver@mozilla.org
parent 5fb49e58
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -1391,14 +1391,7 @@ public:
         *pval = mVal; return JS_TRUE;}

    JSBool NewFunctionObject(XPCCallContext& ccx, XPCNativeInterface* iface,
                             JSObject *parent, jsval* pval)
        {NS_ASSERTION(!IsConstant(),
                      "Only call this if you're sure this is not a constant!");
         if(!IsResolved() && !Resolve(ccx, iface)) return JS_FALSE;
         JSObject* funobj =
            xpc_CloneJSFunction(ccx, JSVAL_TO_OBJECT(mVal), parent);
         if(!funobj) return JS_FALSE;
         *pval = OBJECT_TO_JSVAL(funobj); return JS_TRUE;}
                             JSObject *parent, jsval* pval);

    JSBool IsMethod() const
        {return 0 != (mFlags & METHOD);}
+21 −0
Original line number Diff line number Diff line
@@ -109,6 +109,27 @@ XPCNativeMember::GetCallInfo(XPCCallContext& ccx,
    return JS_TRUE;
}

JSBool
XPCNativeMember::NewFunctionObject(XPCCallContext& ccx,
                                   XPCNativeInterface* iface, JSObject *parent,
                                   jsval* pval)
{
    NS_ASSERTION(!IsConstant(),
                 "Only call this if you're sure this is not a constant!");
    if(!IsResolved() && !Resolve(ccx, iface))
        return JS_FALSE;

    AUTO_MARK_JSVAL(ccx, &mVal);
    JSObject* funobj =
        xpc_CloneJSFunction(ccx, JSVAL_TO_OBJECT(mVal), parent);
    if(!funobj)
        return JS_FALSE;

    *pval = OBJECT_TO_JSVAL(funobj);

    return JS_TRUE;
}

JSBool
XPCNativeMember::Resolve(XPCCallContext& ccx, XPCNativeInterface* iface)
{