From 68682d75b5323ebf45d662dd0d1de563442d147f Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 10 Dec 2021 08:39:21 +0100 Subject: [PATCH 1/2] Fix nullptr dereferencing from std::shared_ptr - Finding from fuzzer - closes https://github.com/assimp/assimp/issues/4237 --- code/AssetLib/DXF/DXFLoader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/AssetLib/DXF/DXFLoader.cpp b/code/AssetLib/DXF/DXFLoader.cpp index 3b20678ad..2f1aa6961 100644 --- a/code/AssetLib/DXF/DXFLoader.cpp +++ b/code/AssetLib/DXF/DXFLoader.cpp @@ -378,6 +378,11 @@ void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& bloc const DXF::Block& bl_src = *(*it).second; for (std::shared_ptr pl_in : bl_src.lines) { + if (!pl_in) { + ASSIMP_LOG_ERROR("DXF: PolyLine instance is nullptr, skipping."); + continue; + } + std::shared_ptr pl_out = std::shared_ptr(new DXF::PolyLine(*pl_in)); if (bl_src.base.Length() || insert.scale.x!=1.f || insert.scale.y!=1.f || insert.scale.z!=1.f || insert.angle || insert.pos.Length()) { From 33c676227233c3b543df53284e905781dbf62c10 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 10 Dec 2021 14:32:45 +0100 Subject: [PATCH 2/2] Update HMPLoader.cpp - Fix possible division by zero - closes https://github.com/assimp/assimp/issues/4235 --- code/AssetLib/HMP/HMPLoader.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/code/AssetLib/HMP/HMPLoader.cpp b/code/AssetLib/HMP/HMPLoader.cpp index 661e4d1b2..0bc152680 100644 --- a/code/AssetLib/HMP/HMPLoader.cpp +++ b/code/AssetLib/HMP/HMPLoader.cpp @@ -473,16 +473,22 @@ void HMPImporter::ReadFirstSkin(unsigned int iNumSkins, const unsigned char *szC // ------------------------------------------------------------------------------------------------ // Generate proepr texture coords -void HMPImporter::GenerateTextureCoords( - const unsigned int width, const unsigned int height) { +void HMPImporter::GenerateTextureCoords(const unsigned int width, const unsigned int height) { ai_assert(nullptr != pScene->mMeshes); ai_assert(nullptr != pScene->mMeshes[0]); ai_assert(nullptr != pScene->mMeshes[0]->mTextureCoords[0]); aiVector3D *uv = pScene->mMeshes[0]->mTextureCoords[0]; - - const float fY = (1.0f / height) + (1.0f / height) / (height - 1); - const float fX = (1.0f / width) + (1.0f / width) / (width - 1); + if (uv == nullptr) { + return; + } + + if (height == 0.0f || width == 0.0) { + return; + } + + const float fY = (1.0f / height) + (1.0f / height) / height; + const float fX = (1.0f / width) + (1.0f / width) / width; for (unsigned int y = 0; y < height; ++y) { for (unsigned int x = 0; x < width; ++x, ++uv) {