Return false instead of crash (#5685)
- Return false instead of crash - closes https://github.com/assimp/assimp/issues/5684pull/5687/head
parent
76de7cedf4
commit
104a70f845
|
@ -192,13 +192,13 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) {
|
||||||
|
|
||||||
for( unsigned int a = 0; a < pMesh->mNumFaces; a++) {
|
for( unsigned int a = 0; a < pMesh->mNumFaces; a++) {
|
||||||
const aiFace& face = pMesh->mFaces[a];
|
const aiFace& face = pMesh->mFaces[a];
|
||||||
|
|
||||||
if( face.mNumIndices != 3) {
|
if( face.mNumIndices != 3) {
|
||||||
bNeed = true;
|
bNeed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!bNeed)
|
if (!bNeed) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!(pMesh->mPrimitiveTypes & aiPrimitiveType_POLYGON)) {
|
else if (!(pMesh->mPrimitiveTypes & aiPrimitiveType_POLYGON)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -213,8 +213,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) {
|
||||||
get_normals = false;
|
get_normals = false;
|
||||||
}
|
}
|
||||||
if( face.mNumIndices <= 3) {
|
if( face.mNumIndices <= 3) {
|
||||||
numOut++;
|
++numOut;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
numOut += face.mNumIndices-2;
|
numOut += face.mNumIndices-2;
|
||||||
max_out = std::max(max_out,face.mNumIndices);
|
max_out = std::max(max_out,face.mNumIndices);
|
||||||
|
@ -222,7 +221,10 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Just another check whether aiMesh::mPrimitiveTypes is correct
|
// 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;
|
aiVector3D *nor_out = nullptr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue