소스 검색

Update ObjFileParser.cpp

Alex 2 년 전
부모
커밋
d3506c24e7
1개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      code/AssetLib/Obj/ObjFileParser.cpp

+ 3 - 0
code/AssetLib/Obj/ObjFileParser.cpp

@@ -458,11 +458,14 @@ void ObjFileParser::getFace(aiPrimitiveType type) {
             //OBJ USES 1 Base ARRAYS!!!!
             int iVal;
             auto end = m_DataIt;
+            // find either the buffer end or the '\0'
             while (end < m_DataItEnd && *end != '\0')
                 ++end;
+            // avoid temporary string allocation if there is a zero
             if (end != m_DataItEnd) {
                 iVal = ::atoi(&(*m_DataIt));
             } else {
+                // otherwise make a zero terminated copy, which is safe to pass to atoi
                 std::string number(&(*m_DataIt), m_DataItEnd - m_DataIt);
                 iVal = ::atoi(number.c_str());
             }