mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 18:23:49 +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")]
|
#[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