diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-01-20 00:24:19 +0100 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-01-20 00:29:01 +0100 |
commit | 2dd373894f76f768a72c9c08096c2598c0b8485b (patch) | |
tree | ece7bbae523d83875e5a57cdc3be7afaf1d6ff81 | |
parent | 00abc243dd2948027fd61729b647ec42f73a4027 (diff) | |
download | android-node-v8-2dd373894f76f768a72c9c08096c2598c0b8485b.tar.gz android-node-v8-2dd373894f76f768a72c9c08096c2598c0b8485b.tar.bz2 android-node-v8-2dd373894f76f768a72c9c08096c2598c0b8485b.zip |
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.
-rw-r--r-- | src/v8_typed_array.cc | 2 | ||||
-rw-r--r-- | test/simple/test-typed-arrays.js | 9 |
2 files changed, 10 insertions, 1 deletions
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); +})(); |