From a6b1a357488fe8ca1cd0e6afae4d83173befc239 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 5 Jul 2022 20:05:10 +0200 Subject: [PATCH 1/2] Try to fix issue 4238 - Fix possible nullptr dereferencing. - closes https://github.com/assimp/assimp/issues/4238 --- code/AssetLib/MDL/MDLMaterialLoader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/AssetLib/MDL/MDLMaterialLoader.cpp b/code/AssetLib/MDL/MDLMaterialLoader.cpp index 2de43d241..cbb69b697 100644 --- a/code/AssetLib/MDL/MDLMaterialLoader.cpp +++ b/code/AssetLib/MDL/MDLMaterialLoader.cpp @@ -448,7 +448,9 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( unsigned int iType, unsigned int iWidth, unsigned int iHeight) { - std::unique_ptr pcNew; + if (szCurrent == nullptr) { + return; + } // get the type of the skin unsigned int iMasked = (unsigned int)(iType & 0xF); @@ -468,6 +470,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( return; } + std::unique_ptr pcNew; pcNew.reset(new aiTexture); pcNew->mHeight = 0; pcNew->mWidth = iWidth; From 5bce9e8ce5a1c999ee33cb2edcde6639b8f00e67 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 5 Jul 2022 20:09:16 +0200 Subject: [PATCH 2/2] Update MDLMaterialLoader.cpp --- code/AssetLib/MDL/MDLMaterialLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/MDL/MDLMaterialLoader.cpp b/code/AssetLib/MDL/MDLMaterialLoader.cpp index cbb69b697..db4b534f2 100644 --- a/code/AssetLib/MDL/MDLMaterialLoader.cpp +++ b/code/AssetLib/MDL/MDLMaterialLoader.cpp @@ -448,6 +448,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( unsigned int iType, unsigned int iWidth, unsigned int iHeight) { + std::unique_ptr pcNew; if (szCurrent == nullptr) { return; } @@ -470,7 +471,6 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( return; } - std::unique_ptr pcNew; pcNew.reset(new aiTexture); pcNew->mHeight = 0; pcNew->mWidth = iWidth;