rynewang opened a new pull request, #48745:
URL: https://github.com/apache/arrow/pull/48745

   ### Rationale for this change
   
   As noted by @wgtmac in 
https://github.com/apache/arrow/pull/48717#discussion_r2665550214, calling 
`std::memcpy` with a nullptr source is undefined behavior according to the C++ 
standard, even when the size is 0.
   
   When `ByteArray` has `len=0` and `ptr=nullptr` (the default-constructed 
state per `types.h:649`), the current code invokes UB.
   
   ### What changes are included in this PR?
   
   Added guards to check `len > 0` before calling `memcpy` in:
   - `TypedStatisticsImpl<ByteArrayType>::Copy` in `statistics.cc`
   - `DictDecoderImpl<ByteArrayType>::SetDict` in `decoder.cc`
   - Test utilities in `statistics_test.cc` and `column_writer_test.cc`
   
   ### Are these changes tested?
   
   Existing tests pass. The fix prevents potential UB that sanitizers or 
optimizing compilers could exploit.
   
   ### Are there any user-facing changes?
   
   No.


-- 
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]

Reply via email to