diff options
author | Anna Henningsen <anna@addaleax.net> | 2017-03-31 08:22:20 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-04-03 10:38:10 +0200 |
commit | 33a19b46ca8ad9dd00f4a563a6960b5de11a3456 (patch) | |
tree | cff3e679a64493b9263e23cb1f29705c9e162117 /lib/v8.js | |
parent | 56e881d0b0b2997b518753cb627eb3b50eeb6f62 (diff) | |
download | android-node-v8-33a19b46ca8ad9dd00f4a563a6960b5de11a3456.tar.gz android-node-v8-33a19b46ca8ad9dd00f4a563a6960b5de11a3456.tar.bz2 android-node-v8-33a19b46ca8ad9dd00f4a563a6960b5de11a3456.zip |
v8: fix offsets for TypedArray deserialization
Fix the offset calculation for deserializing TypedArrays that are
not aligned in their original buffer.
Since `byteOffset` refers to the offset into the source `Buffer`
instance, not its underlying `ArrayBuffer`, that is what should
be passed to `buffer.copy`.
PR-URL: https://github.com/nodejs/node/pull/12143
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/v8.js')
-rw-r--r-- | lib/v8.js | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -177,7 +177,8 @@ class DefaultDeserializer extends Deserializer { } else { // Copy to an aligned buffer first. const copy = Buffer.allocUnsafe(byteLength); - bufferBinding.copy(this.buffer, copy, 0, offset, offset + byteLength); + bufferBinding.copy(this.buffer, copy, 0, + byteOffset, byteOffset + byteLength); return new ctor(copy.buffer, copy.byteOffset, byteLength / BYTES_PER_ELEMENT); |