Skip to content

Commit 659b27a

Browse files
committed
Use safe unaligned loads and stores
1 parent 063e5ed commit 659b27a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cpp/src/arrow/util/byte_stream_split_internal.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ inline void DoSplitStreams(const uint8_t* src, int width, int64_t nvalues,
620620
uint64_t r = (a << 56) | (b << 48) | (c << 40) | (d << 32) | (e << 24) |
621621
(f << 16) | (g << 8) | h;
622622
#endif
623-
*reinterpret_cast<uint64_t*>(&dest[i]) = r;
623+
arrow::util::SafeStore(&dest[i], r);
624624
}
625625
dest_streams[stream] += kBlockSize;
626626
}
@@ -648,7 +648,7 @@ inline void DoMergeStreams(const uint8_t** src_streams, int width, int64_t nvalu
648648
// to their logical places in destination.
649649
const uint8_t* src = src_streams[stream];
650650
for (int i = 0; i < kBlockSize; i += 8) {
651-
uint64_t v = *reinterpret_cast<const uint64_t*>(&src[i]);
651+
uint64_t v = arrow::util::SafeLoadAs<uint64_t>(&src[i]);
652652
#if ARROW_LITTLE_ENDIAN
653653
dest[stream + i * width] = static_cast<uint8_t>(v);
654654
dest[stream + (i + 1) * width] = static_cast<uint8_t>(v >> 8);

0 commit comments

Comments
 (0)