Closed Bug 505494 Opened 10 years ago Closed 10 years ago

apply() doesn't unwrap its second argument

Categories

(Core :: JavaScript Engine, defect)

1.9.1 Branch
x86
macOS
defect
Not set

Tracking

()

RESOLVED FIXED
Tracking Status
status1.9.1 --- ?

People

(Reporter: avarma, Assigned: avarma)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 1 obsolete file)

I'm not sure if this is actually intentional behavior or not, but the following doesn't work when executed from Chrome code:

  (function() {}).apply(this, new XPCSafeJSObjectWrapper([1]));

It raises the following error:

  TypeError second argument to Function.prototype.apply must be an array

Looking at the code for js_fun_apply() in jsfun.cpp, it looks like the code is calling js_IsArrayLike() on the second argument without first calling js_GetWrappedObject() on it (which some other functions, like array_concat() in jsarray.cpp do).

This may be totally intentional, which is fine, I just wanted to throw it out there.  If it's unintentional, I can submit a simple patch to fix it.
Fixes the bug by modifying js_isArrayLike() to unwrap its argument, and adds a mochitest.
Assignee: general → avarma
Status: NEW → ASSIGNED
Attachment #389871 - Flags: review?(mrbkap)
Attachment #389871 - Attachment is obsolete: true
Attachment #390840 - Flags: review?(mrbkap)
Attachment #389871 - Flags: review?(mrbkap)
Attachment #390840 - Flags: review?(mrbkap) → review+
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/ab9450f86fea
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Flags: wanted1.9.2+
status1.9.1: --- → ?
You need to log in before you can comment on or make changes to this bug.