Bug 679509 - Make sure convert hooks in plugin code always return a non-primitive value. r=luke

--HG--
extra : rebase_source : 0efa84079b3acb44b796e8542340e8fbd7e7c303
This commit is contained in:
Jeff Walden 2011-10-11 15:42:15 -07:00
Родитель fee6732327
Коммит 009eea8aae
1 изменённых файлов: 4 добавлений и 16 удалений

Просмотреть файл

@ -160,9 +160,6 @@ static JSBool
NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
JSObject **objp); JSObject **objp);
static JSBool
NPObjWrapper_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
static void static void
NPObjWrapper_Finalize(JSContext *cx, JSObject *obj); NPObjWrapper_Finalize(JSContext *cx, JSObject *obj);
@ -183,7 +180,7 @@ static JSClass sNPObjectJSWrapperClass =
NPObjWrapper_AddProperty, NPObjWrapper_DelProperty, NPObjWrapper_AddProperty, NPObjWrapper_DelProperty,
NPObjWrapper_GetProperty, NPObjWrapper_SetProperty, NPObjWrapper_GetProperty, NPObjWrapper_SetProperty,
(JSEnumerateOp)NPObjWrapper_newEnumerate, (JSEnumerateOp)NPObjWrapper_newEnumerate,
(JSResolveOp)NPObjWrapper_NewResolve, NPObjWrapper_Convert, (JSResolveOp)NPObjWrapper_NewResolve, JS_ConvertStub,
NPObjWrapper_Finalize, nsnull, nsnull, NPObjWrapper_Call, NPObjWrapper_Finalize, nsnull, nsnull, NPObjWrapper_Call,
NPObjWrapper_Construct, nsnull, nsnull NPObjWrapper_Construct, nsnull, nsnull
}; };
@ -1683,18 +1680,6 @@ NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
return JS_TRUE; return JS_TRUE;
} }
static JSBool
NPObjWrapper_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
{
// The sole reason we implement this hook is to prevent the JS
// engine from calling valueOf() on NPObject's. Some NPObject's may
// actually implement a method named valueOf, but it's unlikely to
// behave as the JS engine expects it to. IOW, this is an empty hook
// that overrides what the default hook does.
return JS_TRUE;
}
static void static void
NPObjWrapper_Finalize(JSContext *cx, JSObject *obj) NPObjWrapper_Finalize(JSContext *cx, JSObject *obj)
{ {
@ -2195,6 +2180,9 @@ NPObjectMember_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
case JSTYPE_BOOLEAN: case JSTYPE_BOOLEAN:
case JSTYPE_OBJECT: case JSTYPE_OBJECT:
*vp = memberPrivate->fieldValue; *vp = memberPrivate->fieldValue;
if (!JSVAL_IS_PRIMITIVE(*vp)) {
return JS_ConvertStub(cx, JSVAL_TO_OBJECT(*vp), type, vp);
}
return JS_TRUE; return JS_TRUE;
case JSTYPE_FUNCTION: case JSTYPE_FUNCTION:
// Leave this to NPObjectMember_Call. // Leave this to NPObjectMember_Call.