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

This commit is contained in:
jst@mozilla.org 2008-05-27 22:42:53 -07:00
parent 5fb49e58d7
commit 639c1461f9
2 changed files with 22 additions and 8 deletions

View File

@ -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);}

View File

@ -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)
{