From 9733463d2b141a166bfa2f55ec316066ab0f71b6 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 23 Sep 2017 21:19:01 -0700 Subject: [PATCH] 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 --- src/liballoc/vec_deque.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/liballoc/vec_deque.rs b/src/liballoc/vec_deque.rs index 6836fbb7c4d..6d64e9e303f 100644 --- a/src/liballoc/vec_deque.rs +++ b/src/liballoc/vec_deque.rs @@ -558,7 +558,7 @@ impl VecDeque { .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);