The previous fix is try to fix the SVACE error to ensure null
termination in VmaStringBuilder::Add by resizing the buffer
and appending '\0' after copying. It's noticed that VMA
statistics string is broken after this fix.
We realised that such fix is wrong, because the data is only
used as an input to the function VmaCreateStringCopy, which
takes explicit length and adds null terminator to the created
copy.
We should ignore this SVACE error, as advised by the author
of VMA:
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/pull/463
Change-Id: I5027a4ebe07a102c05a07108cc0108bcf1d73fc1
#ifndef _VMA_STRING_BUILDER_FUNCTIONS
void VmaStringBuilder::Add(const char* pStr)
{
- if (pStr == nullptr)
- return;
-
const size_t strLen = strlen(pStr);
- const size_t oldCount = m_Data.size();
-
- m_Data.resize(oldCount + strLen + 1);
- memcpy(m_Data.data() + oldCount, pStr, strLen + 1);
+ if (strLen > 0)
+ {
+ const size_t oldCount = m_Data.size();
+ m_Data.resize(oldCount + strLen);
+ memcpy(m_Data.data() + oldCount, pStr, strLen);
+ }
}
void VmaStringBuilder::AddNumber(uint32_t num)