Skip to content

Commit

Permalink
Make sure added capacity doesn't overflow usize::MAX
Browse files Browse the repository at this point in the history
  • Loading branch information
ssande7 committed May 7, 2023
1 parent d695430 commit 3913586
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/impl_owned_array.rs
Expand Up @@ -731,6 +731,9 @@ impl<A, D> Array<A, D>
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
Expand Down

0 comments on commit 3913586

Please sign in to comment.