typed arrays: fix DataView endianness regression
Fix an off-by-one error introduced in 9fe3734 that caused a regression in the default endianness used for writes in DataView::setGeneric(). Fixes #4626.
This commit is contained in:
parent
00abc243dd
commit
2dd373894f
@ -714,7 +714,7 @@ class DataView {
|
||||
// NOTE(deanm): args[1]->BooleanValue when the argument was not passed in
|
||||
// gives us the right answer, but seems to be very slow. This seems to be
|
||||
// the cost of calling BooleanValue() on undefined.
|
||||
bool little_endian = args.Length() > 1 ? args[1]->BooleanValue() : false;
|
||||
bool little_endian = args.Length() > 2 ? args[2]->BooleanValue() : false;
|
||||
// TODO(deanm): All of these things should be cacheable.
|
||||
int element_size = v8_typed_array::SizeOfArrayElementForType(
|
||||
args.This()->GetIndexedPropertiesExternalArrayDataType());
|
||||
|
@ -192,3 +192,12 @@ assert.throws(function() {
|
||||
var buf = new DataView(new ArrayBuffer(8));
|
||||
buf.setFloat64(0xffffffff, 0.0, true);
|
||||
}, /Index out of range/);
|
||||
|
||||
// DataView::setGeneric() default endianness regression test,
|
||||
// see https://github.com/joyent/node/issues/4626
|
||||
(function() {
|
||||
var buf = new Uint8Array(2);
|
||||
var view = new DataView(buf);
|
||||
view.setUint16(0, 1);
|
||||
assert.equal(view.getUint16(0), 1);
|
||||
})();
|
||||
|
Loading…
x
Reference in New Issue
Block a user