Use checked_add in VecDeque::append for ZSTs to avoid overflow
This commit is contained in:
parent
26c98689f2
commit
379b18bb0a
@ -1917,7 +1917,7 @@ pub fn split_off(&mut self, at: usize) -> Self
|
|||||||
#[stable(feature = "append", since = "1.4.0")]
|
#[stable(feature = "append", since = "1.4.0")]
|
||||||
pub fn append(&mut self, other: &mut Self) {
|
pub fn append(&mut self, other: &mut Self) {
|
||||||
if T::IS_ZST {
|
if T::IS_ZST {
|
||||||
self.len += other.len;
|
self.len = self.len.checked_add(other.len).expect("capacity overflow");
|
||||||
other.len = 0;
|
other.len = 0;
|
||||||
other.head = 0;
|
other.head = 0;
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user