Browse Source

Fix SEGV write in Assimp::SortByPTypeProcess::Execute (#6318)

* Fix OOB Write in Assimp::SortByPTypeProcess::Execute
Kyungjoon Ko 1 month ago
parent
commit
6d7ea78792
1 changed files with 4 additions and 1 deletions
  1. 4 1
      code/PostProcessing/SortByPTypeProcess.cpp

+ 4 - 1
code/PostProcessing/SortByPTypeProcess.cpp

@@ -188,12 +188,15 @@ void SortByPTypeProcess::Execute(aiScene *pScene) {
 
 
         unsigned int numPolyVerts = 0;
         unsigned int numPolyVerts = 0;
         for (; pFirstFace != pLastFace; ++pFirstFace) {
         for (; pFirstFace != pLastFace; ++pFirstFace) {
-            if (pFirstFace->mNumIndices <= 3)
+            if (pFirstFace->mNumIndices >= 1 && pFirstFace->mNumIndices <= 3)
                 ++aiNumPerPType[pFirstFace->mNumIndices - 1];
                 ++aiNumPerPType[pFirstFace->mNumIndices - 1];
             else {
             else {
                 ++aiNumPerPType[3];
                 ++aiNumPerPType[3];
                 numPolyVerts += pFirstFace->mNumIndices;
                 numPolyVerts += pFirstFace->mNumIndices;
             }
             }
+            if (pFirstFace->mNumIndices == 0) {
+                ASSIMP_LOG_WARN("Face with 0 indices treated as polygon");
+            }
         }
         }
 
 
         VertexWeightTable *avw = ComputeVertexBoneWeightTable(mesh);
         VertexWeightTable *avw = ComputeVertexBoneWeightTable(mesh);