Skip to content

Commit

Permalink
fix: subtraction with underflow on empty FixedSizeBinaryArray (#20109)
Browse files Browse the repository at this point in the history
  • Loading branch information
DzenanJupic authored Dec 3, 2024
1 parent 353bc0e commit 6254203
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions crates/polars-compute/src/cast/binary_to.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,15 @@ pub fn fixed_size_binary_to_binview(from: &FixedSizeBinaryArray) -> BinaryViewAr
// This is zero-copy for the buffer since split just increases the data since
let mut buffer = from.values().clone();
let mut buffers = Vec::with_capacity(num_buffers);
for _ in 0..num_buffers - 1 {
let slice;
(slice, buffer) = buffer.split_at(split_point);
buffers.push(slice);

if let Some(num_buffers) = num_buffers.checked_sub(1) {
for _ in 0..num_buffers {
let slice;
(slice, buffer) = buffer.split_at(split_point);
buffers.push(slice);
}
buffers.push(buffer);
}
buffers.push(buffer);

let mut iter = from.values_iter();
let iter = iter.by_ref();
Expand Down

0 comments on commit 6254203

Please sign in to comment.