diff --git a/src/engine/engine_io.c b/src/engine/engine_io.c index 6c74d0a7..1482e8cb 100644 --- a/src/engine/engine_io.c +++ b/src/engine/engine_io.c @@ -1298,6 +1298,17 @@ const char* mj_validateReferences(const mjModel* m) { #undef MJMODEL_REFERENCES // special logic that doesn't fit in the macro: + for (int i=0; inbody; i++) { + if (i > 0 && m->body_parentid[i] >= i) { + return "Invalid model: bad body_parentid."; + } + if (m->body_rootid[i] > i) { + return "Invalid model: bad body_rootid."; + } + if (m->body_weldid[i] > i) { + return "Invalid model: bad body_weldid."; + } + } for (int i=0; injnt; i++) { if (m->jnt_type[i] >= 4 || m->jnt_type[i] < 0) { return "Invalid model: jnt_type out of bounds."; @@ -1311,6 +1322,11 @@ const char* mj_validateReferences(const mjModel* m) { return "Invalid model: jnt_dofadr out of bounds."; } } + for (int i=0; inv; i++) { + if (m->dof_parentid[i] >= i) { + return "Invalid model: bad dof_parentid."; + } + } for (int i=0; ingeom; i++) { if (m->geom_condim[i] > 6 || m->geom_condim[i] < 0) { return "Invalid model: geom_condim out of bounds.";