From 3d03c6eb48ce3c5ecd936e943fae3adda7eb5de0 Mon Sep 17 00:00:00 2001 From: ri7116 Date: Wed, 8 Oct 2025 20:55:29 +0900 Subject: [PATCH] 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. --- src/js_native_api_v8.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc index 153f49339f702e..6f6bd0042cb0cb 100644 --- a/src/js_native_api_v8.cc +++ b/src/js_native_api_v8.cc @@ -1828,9 +1828,12 @@ napi_status NAPI_CDECL napi_create_bigint_words(napi_env env, v8::MaybeLocal b = v8::BigInt::NewFromWords(context, sign_bit, word_count, words); - CHECK_MAYBE_EMPTY_WITH_PREAMBLE(env, b, napi_generic_failure); + v8::Local local_b; + if (!b.ToLocal(&local_b)) { + return napi_set_last_error(env, napi_generic_failure); + } - *result = v8impl::JsValueFromV8LocalValue(b.ToLocalChecked()); + *result = v8impl::JsValueFromV8LocalValue(local_b); return GET_RETURN_STATUS(env); }