summaryrefslogtreecommitdiff
path: root/lib/v8.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-03-31 08:22:20 +0200
committerAnna Henningsen <anna@addaleax.net>2017-04-03 10:38:10 +0200
commit33a19b46ca8ad9dd00f4a563a6960b5de11a3456 (patch)
treecff3e679a64493b9263e23cb1f29705c9e162117 /lib/v8.js
parent56e881d0b0b2997b518753cb627eb3b50eeb6f62 (diff)
downloadandroid-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.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/v8.js b/lib/v8.js
index 7790f9b334..4205552b7d 100644
--- a/lib/v8.js
+++ b/lib/v8.js
@@ -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);