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

LinkedList`s removeAll method and default deinit may cause stack overflow #996

Open
NickMeepo opened this issue Mar 30, 2022 · 0 comments
Open

Comments

@NickMeepo
Copy link

When triggering removeAll or deinit of very long LinkedList ( like 1...10000000 integers storage),you will get stack overflow. The reason is nodes` recursive releasing.

image

From the image above you will see recursive node deinit pushing into the stack accumulatively and this will cause crash with size increasing.

I suggest to fix this issue by rewriting removeAll, not simply 'self.head = nil', but using a while-loop to releasing each node, and calling removeAll in LinkedList deinit.

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

1 participant