Fix null termination issue for VMA 57/320457/1
authorRichard Huang <r.huang@samsung.com>
Mon, 3 Mar 2025 13:01:06 +0000 (13:01 +0000)
committerRichard Huang <r.huang@samsung.com>
Mon, 3 Mar 2025 13:01:06 +0000 (13:01 +0000)
Change-Id: Ib31c79fc068168b8a48e2cd6ec1b21f508eb80a3

third-party/vma/vk_mem_alloc.h

index c3ccc1250d6f0a1a8e824f62b9dfd6b481c3c2e2..2c1c7f75543d992c95407bd24b8a7a5a451d740f 100644 (file)
@@ -5647,14 +5647,14 @@ private:
 #ifndef _VMA_STRING_BUILDER_FUNCTIONS
 void VmaStringBuilder::Add(const char* pStr)
 {
+    if (pStr == nullptr)
+        return;
+
     const size_t strLen = strlen(pStr);
-    if (strLen > 0)
-    {
-        const size_t oldCount = m_Data.size();
-        m_Data.resize(oldCount + strLen + 1);
-        memcpy(m_Data.data() + oldCount, pStr, strLen);
-        m_Data[oldCount + strLen] = '\0';
-    }
+    const size_t oldCount = m_Data.size();
+
+    m_Data.resize(oldCount + strLen + 1);
+    memcpy(m_Data.data() + oldCount, pStr, strLen + 1);
 }
 
 void VmaStringBuilder::AddNumber(uint32_t num)