Skip to content

Commit 3d03c6e

Browse files
committed
src: use ToLocal() in napi_create_bigint_words
Replace ToLocalChecked() with MaybeLocal::ToLocal() for BigInt::NewFromWords. On failure, return napi_set_last_error(env, napi_generic_failure) to correctly propagate the error instead of risking a crash. This aligns with existing error-handling macros and avoids unchecked conversions.
1 parent 0fb0406 commit 3d03c6e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/js_native_api_v8.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,9 +1828,12 @@ napi_status NAPI_CDECL napi_create_bigint_words(napi_env env,
18281828
v8::MaybeLocal<v8::BigInt> b =
18291829
v8::BigInt::NewFromWords(context, sign_bit, word_count, words);
18301830

1831-
CHECK_MAYBE_EMPTY_WITH_PREAMBLE(env, b, napi_generic_failure);
1831+
v8::Local<v8::BigInt> local_b;
1832+
if (!b.ToLocal(&local_b)) {
1833+
return napi_set_last_error(env, napi_generic_failure);
1834+
}
18321835

1833-
*result = v8impl::JsValueFromV8LocalValue(b.ToLocalChecked());
1836+
*result = v8impl::JsValueFromV8LocalValue(local_b);
18341837
return GET_RETURN_STATUS(env);
18351838
}
18361839

0 commit comments

Comments
 (0)