From bf7cdc522987b5c8675ccaafdb4b2c5d2b19e726 Mon Sep 17 00:00:00 2001 From: Malcolm Nixon Date: Fri, 1 Dec 2023 16:38:08 -0500 Subject: [PATCH] Fix memory corruption and assert failures in convex decomposition This PR fixes how triangular faces are decomposed into vertices and indices. The pre-increment resulted in the indices table skipping entry 0 and potentially overrunning the end of the vertices vector. --- scene/resources/importer_mesh.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/resources/importer_mesh.cpp b/scene/resources/importer_mesh.cpp index 1f4171c07203..66d758080e1a 100644 --- a/scene/resources/importer_mesh.cpp +++ b/scene/resources/importer_mesh.cpp @@ -969,7 +969,7 @@ Vector> ImporterMesh::convex_decompose(const Refvalue; } else { - index = ++vertex_count; + index = vertex_count++; vertex_map[vertex] = index; vertex_w[index] = vertex; }