@@ -307,7 +307,7 @@ class BaseBinaryBuilder
307
307
Status AppendBinaryWithLengths (std::string_view binary, const int32_t * value_lengths,
308
308
int64_t length) {
309
309
ARROW_RETURN_NOT_OK (Reserve (length));
310
- UnsafeAppendToBitmap (/* valid_bytes=*/ nullptr , length);
310
+ UnsafeAppendToBitmap (/* valid_bytes=*/ NULLPTR , length);
311
311
// All values is valid
312
312
int64_t accum_length = 0 ;
313
313
for (int64_t i = 0 ; i < length; ++i) {
@@ -331,7 +331,7 @@ class BaseBinaryBuilder
331
331
Status AppendBinaryWithLengths (std::string_view binary, const int32_t * value_lengths,
332
332
int64_t length, int64_t null_count,
333
333
const uint8_t * valid_bits, int64_t valid_bits_offset) {
334
- if (valid_bits == nullptr || null_count == 0 ) {
334
+ if (valid_bits == NULLPTR || null_count == 0 ) {
335
335
return AppendBinaryWithLengths (binary, value_lengths, length);
336
336
}
337
337
ARROW_RETURN_NOT_OK (Reserve (length));
@@ -351,13 +351,23 @@ class BaseBinaryBuilder
351
351
RETURN_NOT_OK (VisitNullBitmapInline (
352
352
valid_bits, valid_bits_offset, length, null_count,
353
353
[&]() {
354
- offsets_builder_.UnsafeAppend (original_offset + accum_length);
354
+ if (ARROW_PREDICT_FALSE (original_offset + accum_length) >
355
+ std::numeric_limits<int32_t >::max ()) {
356
+ return Status::Invalid (" Binary data is too long" );
357
+ }
358
+ offsets_builder_.UnsafeAppend (
359
+ static_cast <int32_t >(original_offset + accum_length));
355
360
accum_length += value_lengths[length_idx];
356
361
++length_idx;
357
362
return Status::OK ();
358
363
},
359
364
[&]() {
360
- offsets_builder_.UnsafeAppend (original_offset + accum_length);
365
+ if (ARROW_PREDICT_FALSE (original_offset + accum_length) >
366
+ std::numeric_limits<int32_t >::max ()) {
367
+ return Status::Invalid (" Binary data is too long" );
368
+ }
369
+ offsets_builder_.UnsafeAppend (
370
+ static_cast <int32_t >(original_offset + accum_length));
361
371
return Status::OK ();
362
372
}));
363
373
return Status::OK ();
0 commit comments