Merge pull request #5127 from sashashura/5921493454815232

Fix Bad-cast to Assimp::D3DS::Material from invalid vptr in Assimp::ASE::Parser::ParseLV2MaterialBlock
pull/5140/head^2
Kim Kulling 2023-06-27 13:43:03 +02:00 committed by GitHub
commit d2411a7ecd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -479,6 +479,11 @@ void Parser::ParseLV1MaterialListBlock() {
if (TokenMatch(filePtr, "MATERIAL_COUNT", 14)) { if (TokenMatch(filePtr, "MATERIAL_COUNT", 14)) {
ParseLV4MeshLong(iMaterialCount); ParseLV4MeshLong(iMaterialCount);
if (UINT_MAX - iOldMaterialCount < iMaterialCount) {
LogWarning("Out of range: material index is too large");
return;
}
// now allocate enough storage to hold all materials // now allocate enough storage to hold all materials
m_vMaterials.resize(iOldMaterialCount + iMaterialCount, Material("INVALID")); m_vMaterials.resize(iOldMaterialCount + iMaterialCount, Material("INVALID"));
continue; continue;