PlyLoader: Fix operator precedence issue in header check

The previous version might read past end of buffer
pull/1444/head
Turo Lamminen 2017-09-18 15:13:19 +03:00
parent 4652be8f18
commit b74fc9495a
1 changed files with 4 additions and 3 deletions

View File

@ -170,9 +170,10 @@ void PLYImporter::InternReadFile(const std::string& pFile,
std::vector<char> headerCheck;
streamedBuffer.getNextLine(headerCheck);
if ((headerCheck.size() >= 3) && (headerCheck[0] != 'P' && headerCheck[0] != 'p') ||
(headerCheck[1] != 'L' && headerCheck[1] != 'l') ||
(headerCheck[2] != 'Y' && headerCheck[2] != 'y'))
if ((headerCheck.size() < 3) ||
(headerCheck[0] != 'P' && headerCheck[0] != 'p') ||
(headerCheck[1] != 'L' && headerCheck[1] != 'l') ||
(headerCheck[2] != 'Y' && headerCheck[2] != 'y') )
{
streamedBuffer.close();
throw DeadlyImportError("Invalid .ply file: Magic number \'ply\' is no there");