diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 0546e7a53fae90..48df1323ca7215 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -494,7 +494,12 @@ MaybeLocal New(Environment* env, size_t length) { if (length > 0) { CHECK_NOT_NULL(data); - CHECK(length <= kMaxLength); + // V8 currently only allows a maximum Typed Array index of max Smi. + if (length > kMaxLength) { + Isolate* isolate(env->isolate()); + isolate->ThrowException(ERR_BUFFER_TOO_LARGE(isolate)); + return Local(); + } } auto free_callback = [](char* data, void* hint) { free(data); };