You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C++] Null pointer arithmetic in Buffer and MutableBuffer slicing constructors #55445
Describe the bug, including details regarding any error messages, version, and platform.
Currently, the slicing constructors for Buffer (cpp/src/arrow/buffer.h) and MutableBuffer (cpp/src/arrow/buffer.cc) unconditionally add offset to the parent buffer's pointer/address:
When slicing a null-backed buffer where parent->data_ is nullptr or parent->mutable_address() is 0 with a non-zero offset (e.g., SliceBuffer(std::make_shared<Buffer>(nullptr, 16), 8, 8)):
It performs undefined pointer arithmetic on a null pointer ([expr.add]), producing a non-null corrupted address (0x8 instead of nullptr).
It triggers clang-analyzer-core.NullPointerArithm in clang-tidy:
cpp/src/arrow/buffer.cc:167:75: warning: Addition of a null pointer and a nonzero integer value (from variable 'offset') results in undefined behavior [clang-analyzer-core.NullPointerArithm]
Activity