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

pull/450/head
Turo Lamminen 2015-01-26 15:05:18 +02:00
parent af09e68654
commit 16f9ca35d2
1 changed files with 7 additions and 0 deletions

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];