Skip to content

Fix capacity comparison in reserve #44802

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

Merged
merged 2 commits into from
Sep 27, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix capacity comparison in reserve
You can otherwise end up in a situation where you don't actually resize
but still call into handle_cap_increase which then corrupts head/tail.

Closes #44800
  • Loading branch information
sfackler committed Sep 24, 2017
commit 9733463d2b141a166bfa2f55ec316066ab0f71b6
2 changes: 1 addition & 1 deletion src/liballoc/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ impl<T> VecDeque<T> {
.and_then(|needed_cap| needed_cap.checked_next_power_of_two())
.expect("capacity overflow");

if new_cap > self.capacity() {
if new_cap > old_cap {
self.buf.reserve_exact(used_cap, new_cap - used_cap);
unsafe {
self.handle_cap_increase(old_cap);
Expand Down