소스 검색

Avoid reading past EOF when encountering a malformed STL file

Since IsSpaceOrNewLine returns true on '\0' we might try to read past
end of buffer on line 310. Add explicit check to avoid this.
Turo Lamminen 10 년 전
부모
커밋
b39446b7bb
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      code/STLLoader.cpp

+ 1 - 1
code/STLLoader.cpp

@@ -279,7 +279,7 @@ void STLImporter::LoadASCIIFile()
             break;
         }
         // facet normal -0.13 -0.13 -0.98
-        if (!strncmp(sz,"facet",5) && IsSpaceOrNewLine(*(sz+5)))    {
+        if (!strncmp(sz,"facet",5) && IsSpaceOrNewLine(*(sz+5)) && *(sz + 5) != '\0')    {
 
             if (3 != curVertex) {
                 DefaultLogger::get()->warn("STL: A new facet begins but the old is not yet complete");