Skip to content

Commit 396342e

Browse files
rayw000targos
authored andcommitted
src: throw error instead of assertion
PR-URL: #40243 Fixes: #40059 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 8d16f0d commit 396342e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/node_buffer.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,12 @@ MaybeLocal<Object> New(Environment* env,
494494
size_t length) {
495495
if (length > 0) {
496496
CHECK_NOT_NULL(data);
497-
CHECK(length <= kMaxLength);
497+
// V8 currently only allows a maximum Typed Array index of max Smi.
498+
if (length > kMaxLength) {
499+
Isolate* isolate(env->isolate());
500+
isolate->ThrowException(ERR_BUFFER_TOO_LARGE(isolate));
501+
return Local<Object>();
502+
}
498503
}
499504

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

0 commit comments

Comments
 (0)