about summary refs log tree commit diff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-02-25 11:05:21 -0500
committerpommicket <pommicket@gmail.com>2023-02-25 11:05:21 -0500
commit379b18bb0ab07e8f7ba04ca29ba52a1817cec1ce (patch)
tree6b4903f3849cfc3e48acab4361df1bcae02b0ea4
parent26c98689f2060ec834dbe8b8e80b24b31ffd48f2 (diff)
downloadrust-379b18bb0ab07e8f7ba04ca29ba52a1817cec1ce.tar.gz
rust-379b18bb0ab07e8f7ba04ca29ba52a1817cec1ce.zip
Use checked_add in VecDeque::append for ZSTs to avoid overflow
-rw-r--r--library/alloc/src/collections/vec_deque/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs
index 1573b3d77dc..d08c372cd7d 100644
--- a/library/alloc/src/collections/vec_deque/mod.rs
+++ b/library/alloc/src/collections/vec_deque/mod.rs
@@ -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;