mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Use checked_add in VecDeque::append for ZSTs to avoid overflow
This commit is contained in:
parent
26c98689f2
commit
379b18bb0a
@ -1917,7 +1917,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
|
||||
#[stable(feature = "append", since = "1.4.0")]
|
||||
pub fn append(&mut self, other: &mut Self) {
|
||||
if T::IS_ZST {
|
||||
self.len += other.len;
|
||||
self.len = self.len.checked_add(other.len).expect("capacity overflow");
|
||||
other.len = 0;
|
||||
other.head = 0;
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user