diff --git a/src/v8_typed_array.cc b/src/v8_typed_array.cc index bccd1f68c2..a74d295f37 100644 --- a/src/v8_typed_array.cc +++ b/src/v8_typed_array.cc @@ -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()); diff --git a/test/simple/test-typed-arrays.js b/test/simple/test-typed-arrays.js index cf6b760075..8e99af01f8 100644 --- a/test/simple/test-typed-arrays.js +++ b/test/simple/test-typed-arrays.js @@ -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); +})();