Skip to content

Commit

Permalink
ARROW-9047: [Rust] Fix a segfault when setting zero bits in a zero-le…
Browse files Browse the repository at this point in the history
…ngth bitset.

If the mutable bitset is allocated with zero elements it'll have an
address that, when accessed, segfaults. Even if the number of bits (n)
set is zero, it still reads from this invalid address and things crash.

Closes #7360 from maxburke/rust_empty_bitset_fix

Authored-by: Max Burke <max@urbanlogiq.com>
Signed-off-by: Neville Dipale <nevilledips@gmail.com>
  • Loading branch information
maxburke authored and nevi-me committed Jun 6, 2020
1 parent 0043e39 commit e0e8650
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rust/arrow/src/array/builder.rs
Expand Up @@ -349,7 +349,7 @@ impl BufferBuilderTrait<BooleanType> for BufferBuilder<BooleanType> {

fn append_n(&mut self, n: usize, v: bool) -> Result<()> {
self.reserve(n)?;
if v {
if n != 0 && v {
unsafe {
bit_util::set_bits_raw(self.buffer.raw_data_mut(), self.len, self.len + n)
}
Expand Down

0 comments on commit e0e8650

Please sign in to comment.