Skip to content

Commit dfff09c

Browse files
committed
Safe decoder on zero batch_size
1 parent e942c17 commit dfff09c

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

cpp/src/arrow/util/rle_bitmap_internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ inline auto RleBitPackedToBitmapDecoder::GetBatch(BitmapSpanMut out,
395395
rle_size_t batch_size) -> rle_size_t {
396396
using ControlFlow = RleBitPackedParser::ControlFlow;
397397

398+
if (ARROW_PREDICT_FALSE(batch_size == 0 || exhausted())) {
399+
return 0;
400+
}
401+
398402
rle_size_t values_read = 0;
399403

400404
// Remaining from a previous call that would have left some unread data from a run.

cpp/src/arrow/util/rle_encoding_internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,10 @@ auto RleBitPackedDecoder<T>::GetBatch(value_type* out,
791791
rle_size_t batch_size) -> rle_size_t {
792792
using ControlFlow = RleBitPackedParser::ControlFlow;
793793

794+
if (ARROW_PREDICT_FALSE(batch_size == 0 || exhausted())) {
795+
return 0;
796+
}
797+
794798
rle_size_t values_read = 0;
795799

796800
// Remaining from a previous call that would have left some unread data from a run.

0 commit comments

Comments
 (0)