diff --git a/code/ObjFileImporter.cpp b/code/ObjFileImporter.cpp index e1a084d62..10c463c36 100644 --- a/code/ObjFileImporter.cpp +++ b/code/ObjFileImporter.cpp @@ -448,6 +448,10 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel, 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 ]; // 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 ); } - if ( pMesh->mNumVertices <= newIndex ) { - throw DeadlyImportError("OBJ: bad vertex index"); - } - // Get destination face aiFace *pDestFace = &pMesh->mFaces[ outIndex ];