From 871a2a7c8ea1165c272fa2b6b4486d9adbca90f6 Mon Sep 17 00:00:00 2001 From: Alessio Quaglino Date: Mon, 15 May 2023 02:55:00 -0700 Subject: [PATCH] Check that all face indices of a mesh exist in the vertex array. PiperOrigin-RevId: 532049715 Change-Id: Ic42f6ef49f136aa89fb83527db0867afa8be7f08 --- src/user/user_mesh.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/user/user_mesh.cc b/src/user/user_mesh.cc index 4c44aecd..ab334227 100644 --- a/src/user/user_mesh.cc +++ b/src/user/user_mesh.cc @@ -280,6 +280,13 @@ void mjCMesh::Compile(int vfs_provider) { throw mjCError(this, "face data must be a multiple of 3"); } + // check vertices exist + for (int i=0; i= nvert || userface[i] < 0) { + throw mjCError(this, "index in face does not exist in vertex array"); + } + } + // create half-edge structure (if mesh was in XML) if (useredge.empty()) { for (int i=0; i