Browse Source

Fix infinite loop in STL loader

If next character was not part of valid token and not whitespace we
would end up spinning in the loop indefinitely. Fix by using do..while
loop which always skips at least one character.

Fixes testcase hangs/73b42cd3b6d05e2ddb5c0fe5888459bc
Turo Lamminen 10 years ago
parent
commit
6b9f9afd7a
1 changed files with 4 additions and 2 deletions
  1. 4 2
      code/STLLoader.cpp

+ 4 - 2
code/STLLoader.cpp

@@ -326,8 +326,10 @@ void STLImporter::LoadASCIIFile()
 			break;
 			break;
 		}
 		}
 		// else skip the whole identifier
 		// else skip the whole identifier
-		else while (!::IsSpaceOrNewLine(*sz)) {
-			++sz;
+		else {
+			do {
+				++sz;
+			} while (!::IsSpaceOrNewLine(*sz));
 		}
 		}
 	}
 	}