summaryrefslogtreecommitdiff
path: root/src/node_buffer.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2016-06-04 00:40:43 +0200
committerNikolai Vavilov <vvnicholas@gmail.com>2016-06-04 16:03:00 +0300
commitac0665c908e31787c2b5ea5e84d1a05cb4cc6c97 (patch)
treebe32084f6995109098eba0a89e6ebd311b5dc22d /src/node_buffer.cc
parentc4fadbc15de5f7dbbe607e29bf90cbbd8b5fa6f5 (diff)
downloadandroid-node-v8-ac0665c908e31787c2b5ea5e84d1a05cb4cc6c97.tar.gz
android-node-v8-ac0665c908e31787c2b5ea5e84d1a05cb4cc6c97.tar.bz2
android-node-v8-ac0665c908e31787c2b5ea5e84d1a05cb4cc6c97.zip
src: fix ArrayBuffer size for zero fill flag
Use `sizeof()` of the zero fill flag as the byte length of the `zeroFill` array buffer rather than `1`. This fixes running debug builds, which have boundary checks for typed array creations from native code enabled. PR-URL: https://github.com/nodejs/node/pull/7142 Fixes: https://github.com/nodejs/node/issues/7140 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Nikolai Vavilov <vvnicholas@gmail.com>
Diffstat (limited to 'src/node_buffer.cc')
-rw-r--r--src/node_buffer.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/node_buffer.cc b/src/node_buffer.cc
index bb94263ccd..b8accf517c 100644
--- a/src/node_buffer.cc
+++ b/src/node_buffer.cc
@@ -1227,7 +1227,9 @@ void SetupBufferJS(const FunctionCallbackInfo<Value>& args) {
if (auto zero_fill_field = env->isolate_data()->zero_fill_field()) {
CHECK(args[1]->IsObject());
auto binding_object = args[1].As<Object>();
- auto array_buffer = ArrayBuffer::New(env->isolate(), zero_fill_field, 1);
+ auto array_buffer = ArrayBuffer::New(env->isolate(),
+ zero_fill_field,
+ sizeof(*zero_fill_field));
auto name = FIXED_ONE_BYTE_STRING(env->isolate(), "zeroFill");
auto value = Uint32Array::New(array_buffer, 0, 1);
CHECK(binding_object->Set(env->context(), name, value).FromJust());