pitrou commented on code in PR #48745:
URL: https://github.com/apache/arrow/pull/48745#discussion_r2685335759


##########
cpp/src/parquet/types.h:
##########
@@ -704,6 +704,16 @@ static inline std::string ByteArrayToString(const 
ByteArray& a) {
   return std::string(reinterpret_cast<const char*>(a.ptr), a.len);
 }
 
+/// \brief Safe memcpy that avoids undefined behavior when src is nullptr.
+///
+/// According to the C++ standard, calling std::memcpy with a nullptr is 
undefined
+/// behavior even when size is 0. This function guards against that case.
+static inline void SafeMemcpy(void* dest, const void* src, size_t size) {

Review Comment:
   We already have `arrow/util/ubsan.h` and there's a handy function 
`MakeNonNull` there.
   
   But I wouldn't be against adding a `SafeMemcpy` to that same file if it 
makes things easier.



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