Skip to content

Commit 3757123

Browse files
ssande7bluss
authored andcommitted
Make sure added capacity doesn't overflow usize::MAX
1 parent eedc8dd commit 3757123

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
@@ -732,6 +732,9 @@ impl<A, D> Array<A, D>
732732
debug_assert!(axis.index() < self.ndim());
733733
let self_dim = self.raw_dim();
734734
let remaining_shape = self_dim.remove_axis(axis);
735+
736+
// Make sure added capacity doesn't overflow
737+
debug_assert!(remaining_shape.size().checked_mul(additional).is_some());
735738
let len_to_append = remaining_shape.size() * additional;
736739

737740
// Make sure new capacity is still in bounds

0 commit comments

Comments
 (0)