Skip to content

Fix Infinite loop when calling .toString()#296

Open
ssch1337 wants to merge 2 commits intoindutny:masterfrom
ssch1337:master
Open

Fix Infinite loop when calling .toString()#296
ssch1337 wants to merge 2 commits intoindutny:masterfrom
ssch1337:master

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