Merge pull request #4463 from jakrams/user/jakras/bitangent-fuzzer-fix

Prevent nullptr access to normals-array in bitangent computation
pull/4440/head^2
Kim Kulling 2022-04-12 11:10:47 +02:00 committed by GitHub
commit dc8ba61095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 20 deletions

View File

@ -606,7 +606,10 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
}
}
if (needTangents) {
if (target.tangent[0]->count != aim->mNumVertices) {
if (!aiAnimMesh.HasNormals()) {
// prevent nullptr access to aiAnimMesh.mNormals below when no normals are available
ASSIMP_LOG_WARN("Bitangents of target ", i, " in mesh \"", mesh.name, "\" can't be computed, because mesh has no normals.");
} else if (target.tangent[0]->count != aim->mNumVertices) {
ASSIMP_LOG_WARN("Tangents of target ", i, " in mesh \"", mesh.name, "\" does not match the vertex count");
} else {
Tangent *tangent = nullptr;