mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
## Summary Fixes a bug in napi_get_value_bigint_words where the function would return the number of words copied instead of the actual word count needed when the provided buffer is smaller than required. ## The Problem When napi_get_value_bigint_words was called with a buffer smaller than the actual BigInt size, it would incorrectly return the buffer size instead of the actual word count needed. This doesn't match Node.js behavior. ### Example BigInt that requires 2 words: 0x123456789ABCDEF0123456789ABCDEFn Call with buffer for only 1 word - Before fix: word_count = 1 (buffer size) - After fix: word_count = 2 (actual words needed) ## The Fix Changed napi_get_value_bigint_words to always set word_count to the actual number of words in the BigInt, regardless of buffer size. ## Test Plan - Added test test_bigint_word_count that verifies the word count is correctly returned - Added test test_ref_unref_underflow for the existing napi_reference_unref underflow protection - Both tests pass with the fix and match Node.js behavior 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <noreply@anthropic.com>
15 KiB
15 KiB