We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4058a29 commit 17c74e5Copy full SHA for 17c74e5
src/node_api.cc
@@ -3255,6 +3255,14 @@ napi_status napi_create_dataview(napi_env env,
3255
RETURN_STATUS_IF_FALSE(env, value->IsArrayBuffer(), napi_invalid_arg);
3256
3257
v8::Local<v8::ArrayBuffer> buffer = value.As<v8::ArrayBuffer>();
3258
+ if (byte_length + byte_offset > buffer->ByteLength()) {
3259
+ napi_throw_range_error(
3260
+ env,
3261
+ "ERR_NAPI_INVALID_DATAVIEW_ARGS",
3262
+ "byte_offset + byte_length should be less than or "
3263
+ "equal to the size in bytes of the array passed in");
3264
+ return napi_set_last_error(env, napi_generic_failure);
3265
+ }
3266
v8::Local<v8::DataView> DataView = v8::DataView::New(buffer, byte_offset,
3267
byte_length);
3268
0 commit comments