Skip to content

Commit

Permalink
src: fix ArrayBuffer size for zero fill flag
Browse files Browse the repository at this point in the history
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: #7142
Fixes: #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>
  • Loading branch information
addaleax authored and seishun committed Jun 4, 2016
1 parent c4fadbc commit ac0665c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/node_buffer.cc
Expand Up @@ -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());
Expand Down

0 comments on commit ac0665c

Please sign in to comment.