Skip to content

Commit 5f773c8

Browse files
committed
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 (cherry picked from commit 9733463)
1 parent 3c3cd3f commit 5f773c8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/liballoc/vec_deque.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ impl<T> VecDeque<T> {
556556
.and_then(|needed_cap| needed_cap.checked_next_power_of_two())
557557
.expect("capacity overflow");
558558

559-
if new_cap > self.capacity() {
559+
if new_cap > old_cap {
560560
self.buf.reserve_exact(used_cap, new_cap - used_cap);
561561
unsafe {
562562
self.handle_cap_increase(old_cap);

0 commit comments

Comments
 (0)