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

Fix Infinite loop when calling .toString() #296

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ssch1337
Copy link

@ssch1337 ssch1337 commented Jun 7, 2022

If when initializing BigNumber pass '-' and call the .toString() function. An infinite loop will happen because BN.prototype.isZero() only fires if this.length === 1, in which case this.length === 0.

Example:

const BN = require('bn.js');
const a = new BN('-');
console.log(a.toString()); // Infinite loop

@ssch1337 ssch1337 changed the title Infinite loop when calling .toString() Fix Infinite loop when calling .toString() Oct 26, 2022
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.

1 participant