Skip to content

Commit

Permalink
Return false instead of crash (assimp#5685)
Browse files Browse the repository at this point in the history
- Return false instead of crash
- closes assimp#5684
  • Loading branch information
kimkulling authored Jul 23, 2024
1 parent 76de7ce commit 104a70f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions code/PostProcessing/TriangulateProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) {

for( unsigned int a = 0; a < pMesh->mNumFaces; a++) {
const aiFace& face = pMesh->mFaces[a];

if( face.mNumIndices != 3) {
bNeed = true;
}
}
if (!bNeed)
if (!bNeed) {
return false;
}
}
else if (!(pMesh->mPrimitiveTypes & aiPrimitiveType_POLYGON)) {
return false;
Expand All @@ -213,17 +213,19 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) {
get_normals = false;
}
if( face.mNumIndices <= 3) {
numOut++;

++numOut;
} else {
numOut += face.mNumIndices-2;
max_out = std::max(max_out,face.mNumIndices);
}
}

// Just another check whether aiMesh::mPrimitiveTypes is correct
ai_assert(numOut != pMesh->mNumFaces);

if (numOut == pMesh->mNumFaces) {
ASSIMP_LOG_ERROR( "Invalidation detected in the number of indices: does not fit to the primitive type." );
return false;
}

aiVector3D *nor_out = nullptr;

// if we don't have normals yet, but expect them to be a cheap side
Expand Down

0 comments on commit 104a70f

Please sign in to comment.