Check target sizes to avoid reading beyond allocation
parent
d1ef28fa52
commit
add165c4a1
|
@ -536,6 +536,9 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
||||||
Mesh::Primitive::Target &target = targets[i];
|
Mesh::Primitive::Target &target = targets[i];
|
||||||
|
|
||||||
if (needPositions) {
|
if (needPositions) {
|
||||||
|
if (target.position[0]->count != aim->mNumVertices) {
|
||||||
|
DefaultLogger::get()->warn("Positions of target in mesh \"" + mesh.name + "\" does not match the vertex count");
|
||||||
|
} else {
|
||||||
aiVector3D *positionDiff = nullptr;
|
aiVector3D *positionDiff = nullptr;
|
||||||
target.position[0]->ExtractData(positionDiff);
|
target.position[0]->ExtractData(positionDiff);
|
||||||
for (unsigned int vertexId = 0; vertexId < aim->mNumVertices; vertexId++) {
|
for (unsigned int vertexId = 0; vertexId < aim->mNumVertices; vertexId++) {
|
||||||
|
@ -543,7 +546,11 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
||||||
}
|
}
|
||||||
delete[] positionDiff;
|
delete[] positionDiff;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (needNormals) {
|
if (needNormals) {
|
||||||
|
if (target.normal[0]->count != aim->mNumVertices) {
|
||||||
|
DefaultLogger::get()->warn("Normals of target in mesh \"" + mesh.name + "\" does not match the vertex count");
|
||||||
|
} else {
|
||||||
aiVector3D *normalDiff = nullptr;
|
aiVector3D *normalDiff = nullptr;
|
||||||
target.normal[0]->ExtractData(normalDiff);
|
target.normal[0]->ExtractData(normalDiff);
|
||||||
for (unsigned int vertexId = 0; vertexId < aim->mNumVertices; vertexId++) {
|
for (unsigned int vertexId = 0; vertexId < aim->mNumVertices; vertexId++) {
|
||||||
|
@ -551,7 +558,11 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
||||||
}
|
}
|
||||||
delete[] normalDiff;
|
delete[] normalDiff;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (needTangents) {
|
if (needTangents) {
|
||||||
|
if (target.tangent[0]->count != aim->mNumVertices) {
|
||||||
|
DefaultLogger::get()->warn("Tangents of target in mesh \"" + mesh.name + "\" does not match the vertex count");
|
||||||
|
} else {
|
||||||
Tangent *tangent = nullptr;
|
Tangent *tangent = nullptr;
|
||||||
attr.tangent[0]->ExtractData(tangent);
|
attr.tangent[0]->ExtractData(tangent);
|
||||||
|
|
||||||
|
@ -566,6 +577,7 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
||||||
delete[] tangent;
|
delete[] tangent;
|
||||||
delete[] tangentDiff;
|
delete[] tangentDiff;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (mesh.weights.size() > i) {
|
if (mesh.weights.size() > i) {
|
||||||
aiAnimMesh.mWeight = mesh.weights[i];
|
aiAnimMesh.mWeight = mesh.weights[i];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue