Skip to content

Commit

Permalink
src: throw error instead of assertion
Browse files Browse the repository at this point in the history
PR-URL: #40243
Fixes: #40059
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
rayw000 authored and targos committed Oct 23, 2021
1 parent c83f47f commit 7b49e29
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,12 @@ MaybeLocal<Object> 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<Object>();
}
}

auto free_callback = [](char* data, void* hint) { free(data); };
Expand Down

0 comments on commit 7b49e29

Please sign in to comment.