HaoYang670 commented on issue #911:
URL: https://github.com/apache/arrow-rs/issues/911#issuecomment-1128868905
Something I find is that we have to move the check of `null_bit_buffer` size
into `ArrayData::new_unchecked`:
```rust
pub unsafe fn new_unchecked(
data_type: DataType,
len: usize,
null_bit_buffer: Option<Buffer>,
offset: usize,
buffers: Vec<Buffer>,
child_data: Vec<ArrayData>,
) -> Self {
...
if let Some(null_bit_map) = null_bitmap.as_ref() {
let null_bit_buffer = null_bit_map.buffer_ref();
let needed_len = bit_util::ceil(len + offset, 8);
if null_bit_buffer.len() < needed_len {
return Err(ArrowError::InvalidArgumentError(format!(
"null_bit_buffer size too small. got {} needed {}",
null_bit_buffer.len(),
needed_len
)));
}
}
let null_count = count_nulls(null_bit_buffer.as_ref(), offset, len);
...
```
Otherwise, we may panic if the `null_bit_buffer` is too short.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]