Skip to content

Segfault in  #26642

@asfimport

Description

@asfimport

// src/buffer.rs:657
/// Ensures that this buffer has at least capacity slots in this buffer. This will
/// also ensure the new capacity will be a multiple of 64 bytes.
///
/// Returns the new capacity for this buffer.
pub fn reserve(&mut self, capacity: usize) -> Result {
if capacity > self.capacity {
let new_capacity = bit_util::round_upto_multiple_of_64(capacity);
let new_capacity = cmp::max(new_capacity, self.capacity * 2);
let new_data =
unsafe { memory::reallocate(self.data, self.capacity, new_capacity) };
self.data = new_data as *mut u8;
self.capacity = new_capacity;
}
Ok(self.capacity)
}
 
Above code is not checking if new_data is null, which is causing segfault on following memcpy when reallocate failed.

Environment: Ubuntu 20.04. rustc-nightly,
Reporter: Ziru Niu

Related issues:

Note: This issue was originally created as ARROW-10691. Please see the migration documentation for further details.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions