This is an automated email from the ASF dual-hosted git repository.

gangwu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/orc.git


The following commit(s) were added to refs/heads/main by this push:
     new c4fa9fa3d ORC-2027: [C++] Fix undefined behavior in 
DoubleColumnReader::readFloat()
c4fa9fa3d is described below

commit c4fa9fa3d5b16630f5066d79bf4c36d171a2561d
Author: Zehua Zou <[email protected]>
AuthorDate: Thu Oct 16 21:35:56 2025 +0800

    ORC-2027: [C++] Fix undefined behavior in DoubleColumnReader::readFloat()
    
    ### What changes were proposed in this pull request?
    
    Unaligned reads are UB in C++. We can not guarantee that the 
`bufferPointer_` pointer is aligned by `alignof(int32_t)`.
    
    ### How was this patch tested?
    Use UBsan to test in private repo.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    No.
    
    Closes #2444 from HuaHuaY/fix_issue_2027.
    
    Lead-authored-by: Zehua Zou <[email protected]>
    Co-authored-by: Zehua Zou <[email protected]>
    Signed-off-by: Gang Wu <[email protected]>
---
 c++/src/ColumnReader.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/c++/src/ColumnReader.cc b/c++/src/ColumnReader.cc
index 89ff0e024..207bffc38 100644
--- a/c++/src/ColumnReader.cc
+++ b/c++/src/ColumnReader.cc
@@ -421,7 +421,7 @@ namespace orc {
       int32_t bits = 0;
       if (bufferEnd_ - bufferPointer_ >= 4) {
         if (isLittleEndian) {
-          bits = *(reinterpret_cast<const int32_t*>(bufferPointer_));
+          memcpy(&bits, bufferPointer_, sizeof(bits));
         } else {
           bits = static_cast<unsigned char>(bufferPointer_[0]);
           bits |= static_cast<unsigned char>(bufferPointer_[1]) << 8;

Reply via email to