Skip to content

[C++] ConcatenateBuffers triggers a UBSan error when called with an empty buffer #36913

Closed
@sfc-gh-ebrossard

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

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions