Browse Source

Return early when element is TextureFile

In cases where the TextureFile name would start with an integer, `strtoul10` would parse that number and incorrectly set `numOccur` to that number. This caused PLY parsing to fail for vertex positions.

Since TextureFile is a single line, and does not have any follow-up lines, it’s okay to return early
Daniel Hritzkiv 7 years ago
parent
commit
2922753589
1 changed files with 6 additions and 1 deletions
  1. 6 1
      code/PlyParser.cpp

+ 6 - 1
code/PlyParser.cpp

@@ -381,6 +381,11 @@ bool PLY::Element::ParseElement(IOStreamBuffer<char> &streamBuffer, std::vector<
   {
   {
     char* endPos = &buffer[0] + (strlen(&buffer[0]) - 1);
     char* endPos = &buffer[0] + (strlen(&buffer[0]) - 1);
     pOut->szName = std::string(&buffer[0], endPos);
     pOut->szName = std::string(&buffer[0], endPos);
+
+    // go to the next line
+    PLY::DOM::SkipSpacesAndLineEnd(buffer);
+
+    return true;
   }
   }
 
 
   //parse the number of occurrences of this element
   //parse the number of occurrences of this element
@@ -933,7 +938,7 @@ bool PLY::PropertyInstance::ParseValue(const char* &pCur,
 {
 {
   ai_assert(NULL != pCur);
   ai_assert(NULL != pCur);
   ai_assert(NULL != out);
   ai_assert(NULL != out);
-  
+
   //calc element size
   //calc element size
   bool ret = true;
   bool ret = true;
   switch (eType)
   switch (eType)