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 <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
rayw000 authored and BethGriggs committed Nov 24, 2021
1 parent 91c3cf5 commit 789fef1
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 789fef1

Please sign in to comment.