mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 15:33:10 +02:00
Prevent a crash for corrupted GLTF models.
Co-Authored-By: hifiexperiments <hifiexperiments@users.noreply.github.com>
This commit is contained in:
parent
227e8a1ec6
commit
71fec167ec
1 changed files with 6 additions and 1 deletions
|
@ -1239,6 +1239,11 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash&
|
|||
int v2_index = (indices[n + 1] * 3);
|
||||
int v3_index = (indices[n + 2] * 3);
|
||||
|
||||
if (v1_index + 2 >= vertices.size() || v2_index + 2 >= vertices.size() || v3_index + 2 >= vertices.size()) {
|
||||
qWarning(modelformat) << "Indices out of range for model " << _url;
|
||||
break;
|
||||
}
|
||||
|
||||
glm::vec3 v1 = glm::vec3(vertices[v1_index], vertices[v1_index + 1], vertices[v1_index + 2]);
|
||||
glm::vec3 v2 = glm::vec3(vertices[v2_index], vertices[v2_index + 1], vertices[v2_index + 2]);
|
||||
glm::vec3 v3 = glm::vec3(vertices[v3_index], vertices[v3_index + 1], vertices[v3_index + 2]);
|
||||
|
@ -1333,7 +1338,7 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash&
|
|||
}
|
||||
|
||||
if (validatedIndices.size() == 0) {
|
||||
qWarning(modelformat) << "Indices out of range for model " << _url;
|
||||
qWarning(modelformat) << "No valid indices for model " << _url;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue