Sfoglia il codice sorgente

Fix a bug where string erases throws out of range (#6135)

Co-authored-by: Kim Kulling <[email protected]>
Qingyou Zhao 3 mesi fa
parent
commit
af352d6f7c
1 ha cambiato i file con 3 aggiunte e 1 eliminazioni
  1. 3 1
      code/AssetLib/Ply/PlyParser.cpp

+ 3 - 1
code/AssetLib/Ply/PlyParser.cpp

@@ -300,7 +300,9 @@ bool PLY::Element::ParseElement(IOStreamBuffer<char> &streamBuffer, std::vector<
         // the original string identifier
         pOut->szName = std::string(&buffer[0], &buffer[0] + strlen(&buffer[0]));
         auto pos = pOut->szName.find_last_of(' ');
-        pOut->szName.erase(pos, pOut->szName.size());
+        if (pos != std::string::npos) {
+            pOut->szName.erase(pos, pOut->szName.size());
+        }
     }
 
     if (!PLY::DOM::SkipSpaces(buffer))