Fix for out of bounds read in tile cache builder. (#601)

Fix for reading data out of bounds in tile cache builder in
removeVertex.
While removing a vertex data is read from i+1 index from mesh.verts,
which becomes out of bound for the last vertex, which we shouldn't copy
over in this case.
This commit is contained in:
Alexander 2023-03-16 05:04:41 +02:00 committed by GitHub
parent 405cc095ab
commit 3c4a34968a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1558,7 +1558,7 @@ static dtStatus removeVertex(dtTileCachePolyMesh& mesh, const unsigned short rem
}
// Remove vertex.
for (int i = (int)rem; i < mesh.nverts; ++i)
for (int i = (int)rem; i < mesh.nverts - 1; ++i)
{
mesh.verts[i*3+0] = mesh.verts[(i+1)*3+0];
mesh.verts[i*3+1] = mesh.verts[(i+1)*3+1];