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

Infinite loop when inserting Array into RBTree #25

Open
nk327 opened this issue Apr 14, 2017 · 2 comments
Open

Infinite loop when inserting Array into RBTree #25

nk327 opened this issue Apr 14, 2017 · 2 comments

Comments

@nk327
Copy link

nk327 commented Apr 14, 2017

Somewhat of an edge case, but can lead to a bad state in applications using this library -- hanging and high CPU usage.

Repro case:

let rbtree = new RBTree(function(a, b) { return a.value - b.value; });
rbtree.insert( [ ] );
rbtree.insert( [ ] );  // <-- infinite loop

This works ok with BinTree though.

@nk327
Copy link
Author

nk327 commented Apr 14, 2017

Found in package version 1.0.1

@Ekliptor
Copy link

Ekliptor commented Sep 4, 2017

I can confirm this bug is still present in v1.0.2.
The obvious workaround is to create a child class of RBTree and override the insert method with a check Array.isArray(item) == true and abort.

Are there any plans/suggestions for an official fix?

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

No branches or pull requests

2 participants