[C++] ConcatenateBuffers triggers a UBSan error when called with an empty buffer #36913
Closed
Description
Describe the bug, including details regarding any error messages, version, and platform.
If buffer->data()
is nullptr
here, ConcatenateBuffers
calls std::memcpy
with nullptr
for the src
argument, which is undefined behavior:
If either dest or src is an invalid or null pointer, the behavior is undefined, even if count is zero.
The simplest fix is probably to skip the std::memcpy
call if the buffer has zero length.
Component(s)
C++