Skip to content

Commit bd9b8f5

Browse files
committed
Extra check
1 parent 56d3e20 commit bd9b8f5

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

cpp/src/arrow/util/rle_bitmap_internal.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ class BitPackedRunToBitMapDecoder
217217
data_ = run.raw_data_ptr();
218218
values_count_ = run.values_count();
219219
values_read_ = 0;
220+
// This decoder bounds all of its reads by `values_count_` alone and does not
221+
// carry `max_read_bytes`. Its memory safety therefore relies on the producer
222+
// having sized the run to fit the backing buffer. Check that contract here,
223+
// at the point it is relied upon (a negative max means "unbounded").
224+
ARROW_DCHECK(run.raw_data_max_size() < 0 ||
225+
bit_util::BytesForBits(values_count_) <= run.raw_data_max_size());
220226
}
221227

222228
/// Return the number of values that can be advanced.

0 commit comments

Comments
 (0)