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

from_elem is unsound when clone can panic #101

Closed
mbrubeck opened this Issue Jun 14, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@mbrubeck
Contributor

mbrubeck commented Jun 14, 2018

If clone panics during SmallVec::from_elem then uninitialized memory is dropped. [Original report by dbaupp on Reddit.]

This bug was introduced by #93 which is not yet included in the latest published release (0.6.2).

The suggested solution is to use something like SetLenOnDrop to make sure the length is set correctly when destructors run, without inhibiting optimizations.

@mbrubeck mbrubeck added the bug label Jun 14, 2018

mbrubeck added a commit to mbrubeck/rust-smallvec that referenced this issue Jul 18, 2018

@mbrubeck mbrubeck self-assigned this Jul 18, 2018

mbrubeck added a commit to mbrubeck/rust-smallvec that referenced this issue Jul 18, 2018

bors-servo added a commit that referenced this issue Jul 19, 2018

Auto merge of #103 - mbrubeck:panic, r=jdm
Panic-safety fixes

* Make from_elem panic-safe.  Fixes #101.
* Make insert_many panic-safe.  Fixes #96.

r? @SimonSapin or @jdm.  cc @Vurich

<!-- 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/103)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment