From 86aecf395eab6ab4730541bd3da312d75457354a Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 3 Jun 2023 17:27:49 +0000 Subject: [PATCH] Fix Bad-cast to Assimp::D3DS::Material from invalid vptr in Assimp::ASE::Parser::ParseLV2MaterialBlock --- code/AssetLib/ASE/ASEParser.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/AssetLib/ASE/ASEParser.cpp b/code/AssetLib/ASE/ASEParser.cpp index 8e7ca63d7..c43eb42ff 100644 --- a/code/AssetLib/ASE/ASEParser.cpp +++ b/code/AssetLib/ASE/ASEParser.cpp @@ -479,6 +479,11 @@ void Parser::ParseLV1MaterialListBlock() { if (TokenMatch(filePtr, "MATERIAL_COUNT", 14)) { 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 m_vMaterials.resize(iOldMaterialCount + iMaterialCount, Material("INVALID")); continue;