This is an automated email from the ASF dual-hosted git repository. alamb pushed a commit to branch alamb/coalesce-copy-rows-safe in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
commit a5a7da0a1e528223e55e052935dcded6216c3df3 Author: Andrew Lamb <[email protected]> AuthorDate: Wed Oct 21 15:38:32 2026 -0400 Remove unchecked indexing from InProgressArray::copy_rows copy_rows is a safe trait method with no documented precondition, but the primitive and byte view implementations used get_unchecked on offset..offset + len, relying on callers for memory safety. Use ordinary bounds-checked slicing instead (one check per call, not per element). Co-Authored-By: Claude Fable 5.1 <[email protected]> --- arrow-select/src/coalesce/byte_view.rs | 3 +-- arrow-select/src/coalesce/primitive.rs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/arrow-select/src/coalesce/byte_view.rs b/arrow-select/src/coalesce/byte_view.rs index a6697bfdb5..74c10b3fd7 100644 --- a/arrow-select/src/coalesce/byte_view.rs +++ b/arrow-select/src/coalesce/byte_view.rs @@ -408,8 +408,7 @@ impl<B: ByteViewType> InProgressArray for InProgressByteViewArray<B> { } let buffers = s.data_buffers(); - // SAFETY: copy_rows is called with ranges derived from the source array. - let views = unsafe { s.views().as_ref().get_unchecked(offset..offset + len) }; + let views = &s.views().as_ref()[offset..offset + len]; // If there are no data buffers in s (all inlined views), can append the // views/nulls and done diff --git a/arrow-select/src/coalesce/primitive.rs b/arrow-select/src/coalesce/primitive.rs index 62460ab677..b547409c75 100644 --- a/arrow-select/src/coalesce/primitive.rs +++ b/arrow-select/src/coalesce/primitive.rs @@ -164,9 +164,8 @@ impl<T: ArrowPrimitiveType + Debug> InProgressArray for InProgressPrimitiveArray // Copy the values let values = s.values(); - // SAFETY: copy_rows is called with ranges derived from the source array. self.current - .extend_from_slice(unsafe { values.get_unchecked(offset..offset + len) }); + .extend_from_slice(&values[offset..offset + len]); Ok(()) }
