ソースを参照

Merge pull request #455 from turol/master

Fix some infinite loops
Alexander Gessler 10 年 前
コミット
48fa3153c6
2 ファイル変更6 行追加3 行削除
  1. 1 1
      code/PlyParser.cpp
  2. 5 2
      code/STLLoader.cpp

+ 1 - 1
code/PlyParser.cpp

@@ -436,7 +436,7 @@ bool PLY::DOM::ParseHeader (const char* pCur,const char** pCurOut,bool isBinary)
 	*pCurOut = pCur;
 
 	// parse all elements
-	while (true)
+	while ((*pCur) != '\0')
 	{
 		// skip all comments
 		PLY::DOM::SkipComments(pCur,&pCur);

+ 5 - 2
code/STLLoader.cpp

@@ -308,6 +308,7 @@ void STLImporter::LoadASCIIFile()
 		{
 			if (3 == curVertex)	{
 				DefaultLogger::get()->error("STL: a facet with more than 3 vertices has been found");
+				++sz;
 			}
 			else
 			{
@@ -326,8 +327,10 @@ void STLImporter::LoadASCIIFile()
 			break;
 		}
 		// else skip the whole identifier
-		else while (!::IsSpaceOrNewLine(*sz)) {
-			++sz;
+		else {
+			do {
+				++sz;
+			} while (!::IsSpaceOrNewLine(*sz));
 		}
 	}