Fix out-of-bounds read when OFF file contains no vertices

This commit is contained in:
Turo Lamminen
2015-01-26 15:05:18 +02:00
parent af09e68654
commit 16f9ca35d2

View File

@@ -127,6 +127,13 @@ void OFFImporter::InternReadFile( const std::string& pFile,
const unsigned int numVertices = strtoul10(sz,&sz);SkipSpaces(&sz);
const unsigned int numFaces = strtoul10(sz,&sz);
if (!numVertices) {
throw DeadlyImportError("OFF: There are no valid vertices");
}
if (!numFaces) {
throw DeadlyImportError("OFF: There are no valid faces");
}
pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes = 1 ];
aiMesh* mesh = pScene->mMeshes[0] = new aiMesh();
aiFace* faces = mesh->mFaces = new aiFace [mesh->mNumFaces = numFaces];