Closed
Bug 1133377
Opened 11 years ago
Closed 11 years ago
DataView constructor handles explicitly undefined parameters wrong
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla39
Tracking | Status | |
---|---|---|
firefox39 | --- | fixed |
People
(Reporter: punk.song4856, Assigned: jonco)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
1.63 KB,
patch
|
sfink
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0
Build ID: 20150215004021
Steps to reproduce:
var buff = new ArrayBuffer(100);
view = new DataView(buff, undefined, undefined);
At this moment (Feb 16 2015) the bug is also present in the Nightly build.
Actual results:
returns DataView { buffer: ArrayBuffer, byteLength: 0, byteOffset: 0 }
this is a problem because:
function CustomView(buffer, offset, length) {
this.theView = new DataView(buffer, offset, length);
// ...
}
so if I use:
var view = new CustomView(buffer);
it gives me an unusable object.
Expected results:
should return DataView { buffer: ArrayBuffer, byteLength: 100, byteOffset: 0 }
![]() |
||
Updated•11 years ago
|
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
![]() |
||
Comment 1•11 years ago
|
||
Looks to me like DataViewObject::construct is checking args.length() > 2 whereas per spec it should be checking whether args.get(2).isUndefined() is true.
![]() |
||
Updated•11 years ago
|
Assignee | ||
Comment 2•11 years ago
|
||
As suggested, check whether argument is undefined.
Assignee: nobody → jcoppeard
Attachment #8569984 -
Flags: review?(sphink)
Comment 3•11 years ago
|
||
Comment on attachment 8569984 [details] [diff] [review]
bug1133377-data-view-constructor
Review of attachment 8569984 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/src/vm/TypedArrayObject.cpp
@@ +1061,5 @@
> JSMSG_ARG_INDEX_OUT_OF_RANGE, "1");
> return false;
> }
>
> + if (args.length() > 2 && !args[2].isUndefined()) {
I'm with bz, I would expect args.get(2).isUndefined()
This is a spec change from the original Khronos draft, I think. I don't think the es-discuss people had even settled on variable arg list handling then. (And typed arrays weren't in ES back then anyway.) I wonder if there are more of these lurking.
Attachment #8569984 -
Flags: review?(sphink) → review+
Assignee | ||
Comment 4•11 years ago
|
||
Status: NEW → RESOLVED
Closed: 11 years ago
status-firefox39:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
You need to log in
before you can comment on or make changes to this bug.
Description
•