From 50b00d33b513e2ccbfdf1f026186ff32107fe71c Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 26 Jan 2022 19:22:52 +0100 Subject: [PATCH] HMP: Fix override during copying position data - Fix override - closes https://github.com/assimp/assimp/issues/4235 --- code/AssetLib/HMP/HMPLoader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/AssetLib/HMP/HMPLoader.cpp b/code/AssetLib/HMP/HMPLoader.cpp index 93d69dbcd..23b84a9c2 100644 --- a/code/AssetLib/HMP/HMPLoader.cpp +++ b/code/AssetLib/HMP/HMPLoader.cpp @@ -373,12 +373,16 @@ void HMPImporter::CreateOutputFaceList(unsigned int width, unsigned int height) aiVector3D *pcUVOut(pcUVs); // Build the terrain square + const unsigned int upperBound = pcMesh->mNumVertices; unsigned int iCurrent = 0; for (unsigned int y = 0; y < height - 1; ++y) { for (unsigned int x = 0; x < width - 1; ++x, ++pcFaceOut) { pcFaceOut->mNumIndices = 4; pcFaceOut->mIndices = new unsigned int[4]; - + if ((y * width + x + 1) >= upperBound){ + continue; + } + ai_assert(upperBound *pcVertOut++ = pcMesh->mVertices[y * width + x]; *pcVertOut++ = pcMesh->mVertices[(y + 1) * width + x]; *pcVertOut++ = pcMesh->mVertices[(y + 1) * width + x + 1];