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

(cherry picked from commit 9733463)
  • Loading branch information
sfackler committed Sep 27, 2017
1 parent 3c3cd3f commit 5f773c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/liballoc/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,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 5f773c8

Please sign in to comment.