Skip to content

Commit 3913586

Browse files
committed
Make sure added capacity doesn't overflow usize::MAX
1 parent d695430 commit 3913586

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/impl_owned_array.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,9 @@ impl<A, D> Array<A, D>
731731
debug_assert!(axis.index() < self.ndim());
732732
let self_dim = self.raw_dim();
733733
let remaining_shape = self_dim.remove_axis(axis);
734+
735+
// Make sure added capacity doesn't overflow
736+
debug_assert!(remaining_shape.size().checked_mul(additional).is_some());
734737
let len_to_append = remaining_shape.size() * additional;
735738

736739
// Make sure new capacity is still in bounds

0 commit comments

Comments
 (0)