From db2500c39341f8169ffd4fbd2e26cd4aee293437 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 23 Dec 2021 12:28:43 +0100 Subject: [PATCH] MDL: Do not try to copy empty embedded texture - When an embedded texture is empty, skip it instead of trying to copy it. This must fail. - closes https://github.com/assimp/assimp/issues/4238 - Found from the Google fuzzer. --- code/AssetLib/MDL/MDLMaterialLoader.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/MDL/MDLMaterialLoader.cpp b/code/AssetLib/MDL/MDLMaterialLoader.cpp index 62320814a..4f441a054 100644 --- a/code/AssetLib/MDL/MDLMaterialLoader.cpp +++ b/code/AssetLib/MDL/MDLMaterialLoader.cpp @@ -463,8 +463,12 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( ASSIMP_LOG_WARN("Found a reference to an embedded DDS texture, " "but texture height is not equal to 1, which is not supported by MED"); } - - pcNew.reset(new aiTexture()); + if (iWidth == 0) { + ASSIMP_LOG_ERROR("Found a reference to an embedded DDS texture, but texture width is zero, aborting import."); + return; + } + + pcNew.reset(new aiTexture); pcNew->mHeight = 0; pcNew->mWidth = iWidth;