Merge pull request #1654 from faulesocke/master

Fix buffer overflow in obj loader
pull/1657/head
Kim Kulling 2017-12-23 19:05:54 +01:00 committed by GitHub
commit 885c32e8cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -448,6 +448,10 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
throw DeadlyImportError( "OBJ: vertex index out of range" ); throw DeadlyImportError( "OBJ: vertex index out of range" );
} }
if ( pMesh->mNumVertices <= newIndex ) {
throw DeadlyImportError("OBJ: bad vertex index");
}
pMesh->mVertices[ newIndex ] = pModel->m_Vertices[ vertex ]; pMesh->mVertices[ newIndex ] = pModel->m_Vertices[ vertex ];
// Copy all normals // Copy all normals
@ -479,10 +483,6 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
pMesh->mTextureCoords[ 0 ][ newIndex ] = aiVector3D( coord3d.x, coord3d.y, coord3d.z ); pMesh->mTextureCoords[ 0 ][ newIndex ] = aiVector3D( coord3d.x, coord3d.y, coord3d.z );
} }
if ( pMesh->mNumVertices <= newIndex ) {
throw DeadlyImportError("OBJ: bad vertex index");
}
// Get destination face // Get destination face
aiFace *pDestFace = &pMesh->mFaces[ outIndex ]; aiFace *pDestFace = &pMesh->mFaces[ outIndex ];