Skip to content

Conversation

@gupta-ji6
Copy link
Contributor

Summary

This PR closes #80. We have currently added a patch for the same & it seems to be working as expected in our testing.

This is my first PR on this project, so let me know I should update my PR with anything more.

Why This Fix Works

  1. Prevents 0-length buffers: Math.max(1, this.byteLength()) ensures minimum 1-byte buffer
  2. Maintains compatibility: For non-zero values, behavior is identical
  3. Aligns with standard: Matches bn.js behavior for consistency - https://github.com/indutny/bn.js/blob/6db7c3818569423b94ebcf2bdff90fcfb9c47f6d/lib/bn.js#L577

@mrousavy
Copy link
Member

super cool thanks! also very helpful that you compared this with bn.js behaviour. lgtm!

@mrousavy mrousavy merged commit b5e9567 into margelo:main Jul 21, 2025
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: toArrayLike() crashes with zero-valued BigNumber

2 participants