Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n-api: return napi_invalid_arg on napi_create_bigint_words #31312

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/js_native_api_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1530,10 +1530,8 @@ napi_status napi_create_bigint_words(napi_env env,

v8::Local<v8::Context> context = env->context();

if (word_count > INT_MAX) {
napi_throw_range_error(env, nullptr, "Maximum BigInt size exceeded");
return napi_set_last_error(env, napi_pending_exception);
}
RETURN_STATUS_IF_FALSE(
env, word_count <= INT_MAX, napi_invalid_arg);

v8::MaybeLocal<v8::BigInt> b = v8::BigInt::NewFromWords(
context, sign_bit, word_count, words);
Expand Down
4 changes: 2 additions & 2 deletions test/js-native-api/test_bigint/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ const {
});

assert.throws(CreateTooBigBigInt, {
name: 'RangeError',
message: 'Maximum BigInt size exceeded',
name: 'Error',
message: 'Invalid argument',
});