MD3: Fix crash on invalid vertex index

pull/820/head
Turo Lamminen 2016-03-12 21:50:34 +02:00
parent b0f453dba8
commit da0b180901
1 changed files with 7 additions and 3 deletions

View File

@ -1000,9 +1000,13 @@ void MD3Importer::InternReadFile( const std::string& pFile,
// Read vertices
aiVector3D& vec = pcMesh->mVertices[iCurrent];
vec.x = pcVertices[ pcTriangles->INDEXES[c]].X*AI_MD3_XYZ_SCALE;
vec.y = pcVertices[ pcTriangles->INDEXES[c]].Y*AI_MD3_XYZ_SCALE;
vec.z = pcVertices[ pcTriangles->INDEXES[c]].Z*AI_MD3_XYZ_SCALE;
uint32_t index = pcTriangles->INDEXES[c];
if (index >= pcSurfaces->NUM_VERTICES) {
throw DeadlyImportError( "MD3: Invalid vertex index");
}
vec.x = pcVertices[index].X*AI_MD3_XYZ_SCALE;
vec.y = pcVertices[index].Y*AI_MD3_XYZ_SCALE;
vec.z = pcVertices[index].Z*AI_MD3_XYZ_SCALE;
// Convert the normal vector to uncompressed float3 format
aiVector3D& nor = pcMesh->mNormals[iCurrent];