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

fn extend leaks memory if the iterator panics #136

Closed
Zoxc opened this issue Dec 28, 2018 · 1 comment
Closed

fn extend leaks memory if the iterator panics #136

Zoxc opened this issue Dec 28, 2018 · 1 comment

Comments

@Zoxc
Copy link

Zoxc commented Dec 28, 2018

No description provided.

@mbrubeck
Copy link
Collaborator

mbrubeck commented Jan 4, 2019

I believe this could be fixed by using the SetLenOnDrop type added in 1f40252.

mbrubeck added a commit to mbrubeck/rust-smallvec that referenced this issue Jan 4, 2019
This ensures that the length of the SmallVec is updated even if the
iterator panics in `next`.

This uses `SetLenOnDrop` rather than setting the length inside the loop,
because otherwise this suffers from the same optimization issue as
rust-lang/rust#36355.

Fixes servo#136.
bors-servo pushed a commit that referenced this issue Jan 4, 2019
Don't leak on panic in extend

This ensures that the length of the SmallVec is updated even if the iterator panics in `next`.

This uses `SetLenOnDrop` rather than setting the length inside the loop, because otherwise this suffers from the same optimization issue as rust-lang/rust#36355.

Fixes #136.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-smallvec/137)
<!-- Reviewable:end -->
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