Bug 314874: Function.call/apply pass thisArg.valueOf() as this value when thisArg is not a primitive, r=brendan

This commit is contained in:
crowder%fiverocks.com 2007-01-17 00:27:36 +00:00
parent 29ed6ecfe7
commit 743598bdfe

View File

@ -1582,7 +1582,9 @@ fun_call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
obj = NULL;
} else {
/* Otherwise convert the first arg to 'this' and skip over it. */
if (!js_ValueToObject(cx, argv[0], &obj))
if (!JSVAL_IS_PRIMITIVE(argv[0]))
obj = JSVAL_TO_OBJECT(argv[0]);
else if (!js_ValueToObject(cx, argv[0], &obj))
return JS_FALSE;
argc--;
argv++;
@ -1669,7 +1671,9 @@ fun_apply(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
}
/* Convert the first arg to 'this' and skip over it. */
if (!js_ValueToObject(cx, argv[0], &obj))
if (!JSVAL_IS_PRIMITIVE(argv[0]))
obj = JSVAL_TO_OBJECT(argv[0]);
else if (!js_ValueToObject(cx, argv[0], &obj))
return JS_FALSE;
/* Allocate stack space for fval, obj, and the args. */