mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Use checked_add in VecDeque::append for ZSTs to avoid overflow
This commit is contained in:
@@ -1917,7 +1917,7 @@ pub fn split_off(&mut self, at: usize) -> Self
|
||||
#[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;
|
||||
|
||||
Reference in New Issue
Block a user