diff --git a/crates/polars-arrow/src/array/mod.rs b/crates/polars-arrow/src/array/mod.rs index 45189274d057..76d68d0a1b5a 100644 --- a/crates/polars-arrow/src/array/mod.rs +++ b/crates/polars-arrow/src/array/mod.rs @@ -444,8 +444,11 @@ macro_rules! impl_sliced { #[inline] #[must_use] pub fn sliced(self, offset: usize, length: usize) -> Self { + let total = offset + .checked_add(length) + .expect("offset + length overflowed"); assert!( - offset + length <= self.len(), + total <= self.len(), "the offset of the new Buffer cannot exceed the existing length" ); unsafe { Self::sliced_unchecked(self, offset, length) }