Skip to content

Commit 9733463

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
1 parent 24831c7 commit 9733463

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
@@ -558,7 +558,7 @@ impl<T> VecDeque<T> {
558558
.and_then(|needed_cap| needed_cap.checked_next_power_of_two())
559559
.expect("capacity overflow");
560560

561-
if new_cap > self.capacity() {
561+
if new_cap > old_cap {
562562
self.buf.reserve_exact(used_cap, new_cap - used_cap);
563563
unsafe {
564564
self.handle_cap_increase(old_cap);

0 commit comments

Comments
 (0)