Skip to content

Commit

Permalink
fix: Checking overflow in Sliced function (#21207)
Browse files Browse the repository at this point in the history
  • Loading branch information
hemanth94 authored Feb 15, 2025
1 parent db97383 commit adcfdce
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/polars-arrow/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down

0 comments on commit adcfdce

Please sign in to comment.