Skip to content

Commit 39d1d4c

Browse files
dsprenkelsritchie46
authored andcommitted
fix: Fix the loop bounds in BitmapBuilder::extend_each_repeated_from_slice_unchecked (#26928)
1 parent 0f5ae40 commit 39d1d4c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

crates/polars-arrow/src/bitmap/builder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,14 @@ impl BitmapBuilder {
242242
length: usize,
243243
repeats: usize,
244244
) {
245+
debug_assert!(8 * slice.len() >= offset + length);
245246
if repeats == 0 {
246247
return;
247248
}
248249
if repeats == 1 {
249250
return self.extend_from_slice_unchecked(slice, offset, length);
250251
}
251-
for bit_idx in offset..length {
252+
for bit_idx in offset..(offset + length) {
252253
let bit = (*slice.get_unchecked(bit_idx / 8) >> (bit_idx % 8)) & 1 != 0;
253254
self.extend_constant(repeats, bit);
254255
}

py-polars/tests/unit/operations/test_inequality_join.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
if TYPE_CHECKING:
1616
from hypothesis.strategies import DrawFn, SearchStrategy
1717

18+
from tests.conftest import PlMonkeyPatch
19+
1820

1921
@pytest.mark.parametrize(
2022
("pred_1", "pred_2"),
@@ -690,3 +692,4 @@ def test_boolean_predicate_join_where() -> None:
690692
assert "NESTED LOOP JOIN" in plan
691693

692694
assert_frame_equal(q.collect(), expect)
695+

0 commit comments

Comments
 (0)