diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index cedf4319f8b..c93b51552f2 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -189,6 +189,7 @@ Ref Mesh::generate_triangle_mesh() const { if (primitive == PRIMITIVE_TRIANGLES) { for (int j = 0; j < ic; j++) { int index = ir[j]; + ERR_FAIL_COND_V(index >= vc, Ref()); facesw[widx++] = vr[index]; } } else { // PRIMITIVE_TRIANGLE_STRIP