From 3757123f5072cf1128a948a9da8c6cb2408a6024 Mon Sep 17 00:00:00 2001 From: ssande7 <1731652+ssande7@users.noreply.github.com> Date: Sun, 7 May 2023 20:47:39 +1000 Subject: [PATCH] Make sure added capacity doesn't overflow usize::MAX --- src/impl_owned_array.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/impl_owned_array.rs b/src/impl_owned_array.rs index ecb5aa43f..443cb5e44 100644 --- a/src/impl_owned_array.rs +++ b/src/impl_owned_array.rs @@ -732,6 +732,9 @@ impl Array debug_assert!(axis.index() < self.ndim()); let self_dim = self.raw_dim(); let remaining_shape = self_dim.remove_axis(axis); + + // Make sure added capacity doesn't overflow + debug_assert!(remaining_shape.size().checked_mul(additional).is_some()); let len_to_append = remaining_shape.size() * additional; // Make sure new capacity is still in bounds