Skip to content

Commit ac0665c

Browse files
addaleaxseishun
authored andcommitted
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: #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>
1 parent c4fadbc commit ac0665c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/node_buffer.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,9 @@ void SetupBufferJS(const FunctionCallbackInfo<Value>& args) {
12271227
if (auto zero_fill_field = env->isolate_data()->zero_fill_field()) {
12281228
CHECK(args[1]->IsObject());
12291229
auto binding_object = args[1].As<Object>();
1230-
auto array_buffer = ArrayBuffer::New(env->isolate(), zero_fill_field, 1);
1230+
auto array_buffer = ArrayBuffer::New(env->isolate(),
1231+
zero_fill_field,
1232+
sizeof(*zero_fill_field));
12311233
auto name = FIXED_ONE_BYTE_STRING(env->isolate(), "zeroFill");
12321234
auto value = Uint32Array::New(array_buffer, 0, 1);
12331235
CHECK(binding_object->Set(env->context(), name, value).FromJust());

0 commit comments

Comments
 (0)