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
This commit is contained in:
parent
24831c7221
commit
9733463d2b
@ -558,7 +558,7 @@ impl<T> VecDeque<T> {
|
|||||||
.and_then(|needed_cap| needed_cap.checked_next_power_of_two())
|
.and_then(|needed_cap| needed_cap.checked_next_power_of_two())
|
||||||
.expect("capacity overflow");
|
.expect("capacity overflow");
|
||||||
|
|
||||||
if new_cap > self.capacity() {
|
if new_cap > old_cap {
|
||||||
self.buf.reserve_exact(used_cap, new_cap - used_cap);
|
self.buf.reserve_exact(used_cap, new_cap - used_cap);
|
||||||
unsafe {
|
unsafe {
|
||||||
self.handle_cap_increase(old_cap);
|
self.handle_cap_increase(old_cap);
|
||||||
|
Loading…
Reference in New Issue
Block a user