Avoid calling memcpy from empty string views
ubsan is unhappy when passing a nullptr as the source pointer to memcpy even if the length is 0. Fixes #4720
This commit is contained in:
parent
efa45f8bdd
commit
d076c033e7
|
@ -16,6 +16,8 @@ StringDataPtr StringData::create(ArrayView<const StringView> strs)
|
|||
auto* data = reinterpret_cast<char*>(res + 1);
|
||||
for (auto& str : strs)
|
||||
{
|
||||
if (str.length() == 0) // memccpy(..., nullptr, 0) is UB
|
||||
continue;
|
||||
memcpy(data, str.begin(), (size_t)str.length());
|
||||
data += (int)str.length();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user