Skip to content

Commit

Permalink
Use checked_add in VecDeque::append for ZSTs to avoid overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
pommicket committed Feb 25, 2023
1 parent 26c9868 commit 379b18b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion library/alloc/src/collections/vec_deque/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 379b18b

Please sign in to comment.