diff --git a/arrow-buffer/src/builder/offset.rs b/arrow-buffer/src/builder/offset.rs index 1ef0e3170c96..a51ca5f01d76 100644 --- a/arrow-buffer/src/builder/offset.rs +++ b/arrow-buffer/src/builder/offset.rs @@ -70,8 +70,11 @@ impl OffsetBufferBuilder { /// /// Panics if offsets overflow `O` pub fn finish_cloned(&self) -> OffsetBuffer { - O::from_usize(self.last_offset).expect("overflow"); - unsafe { OffsetBuffer::new_unchecked(self.offsets.clone().into()) } + let cloned = Self { + offsets: self.offsets.clone(), + last_offset: self.last_offset, + }; + cloned.finish() } } diff --git a/arrow-buffer/src/util/bit_mask.rs b/arrow-buffer/src/util/bit_mask.rs index d4c2fa4744e1..83c395db8c03 100644 --- a/arrow-buffer/src/util/bit_mask.rs +++ b/arrow-buffer/src/util/bit_mask.rs @@ -127,16 +127,16 @@ unsafe fn set_upto_64bits( } /// # Safety -/// The caller must ensure all arguments are within the valid range. +/// The caller must ensure `data` has `offset..(offset + 8)` range, and `count <= 8`. #[inline] unsafe fn read_bytes_to_u64(data: &[u8], offset: usize, count: usize) -> u64 { debug_assert!(count <= 8); - let mut tmp = std::mem::MaybeUninit::::new(0); + let mut tmp: u64 = 0; let src = data.as_ptr().add(offset); unsafe { - std::ptr::copy_nonoverlapping(src, tmp.as_mut_ptr() as *mut u8, count); - tmp.assume_init() + std::ptr::copy_nonoverlapping(src, &mut tmp as *mut _ as *mut u8, count); } + tmp } /// # Safety