Skip to content

Commit

Permalink
Fix capacity comparison in reserve
Browse files Browse the repository at this point in the history
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
1 parent 24831c7 commit 9733463
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/liballoc/vec_deque.rs
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

0 comments on commit 9733463

Please sign in to comment.