From 0ba57202f76d50a08495394fd5cf5f1e35ac9a89 Mon Sep 17 00:00:00 2001 From: Mike Feldstein Date: Thu, 16 Aug 2018 13:56:35 -0700 Subject: [PATCH 1/2] Use array delete command vs object delete since mMeshes is allocated with new[] --- code/SplitByBoneCountProcess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/SplitByBoneCountProcess.cpp b/code/SplitByBoneCountProcess.cpp index b33b6d95c..6faf11086 100644 --- a/code/SplitByBoneCountProcess.cpp +++ b/code/SplitByBoneCountProcess.cpp @@ -393,7 +393,7 @@ void SplitByBoneCountProcess::UpdateNode( aiNode* pNode) const newMeshList.insert( newMeshList.end(), replaceMeshes.begin(), replaceMeshes.end()); } - delete pNode->mMeshes; + delete [] pNode->mMeshes; pNode->mNumMeshes = static_cast(newMeshList.size()); pNode->mMeshes = new unsigned int[pNode->mNumMeshes]; std::copy( newMeshList.begin(), newMeshList.end(), pNode->mMeshes); From 82f3d40d600aa98285c1348f8f7fd1c12495787c Mon Sep 17 00:00:00 2001 From: gstanlo Date: Fri, 17 Aug 2018 13:26:33 -0700 Subject: [PATCH 2/2] Fixes crash when importing invalid glTF/2.0 files Skips some glTF/2.0 uv processing if the count of uvs in the attribute stream doesn't match the vertex count. This happens with some malformed glTF/2.0 files, and the change will allow them to be processed properly. Without the change, an access violation will occur several lines below if uv count is less than the position count. --- code/glTF2Importer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/glTF2Importer.cpp b/code/glTF2Importer.cpp index 15c338716..39587edbd 100644 --- a/code/glTF2Importer.cpp +++ b/code/glTF2Importer.cpp @@ -436,6 +436,12 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r) } for (size_t tc = 0; tc < attr.texcoord.size() && tc < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++tc) { + if (attr.texcoord[tc]->count != aim->mNumVertices) { + DefaultLogger::get()->warn("Texcoord stream size in mesh \"" + mesh.name + + "\" does not match the vertex count"); + continue; + } + attr.texcoord[tc]->ExtractData(aim->mTextureCoords[tc]); aim->mNumUVComponents[tc] = attr.texcoord[tc]->GetNumComponents();