Ensure that mjModel->nbody is never zero.

nbody is already checked to be non-negative, but various pieces of code assume it's nonzero (because there's always a world body).

PiperOrigin-RevId: 465339241
Change-Id: I38ce3764074d03bf9a703aa490964c1eb83cc1da
This commit is contained in:
Nimrod Gileadi
2022-08-04 09:58:42 -07:00
committed by Copybara-Service
parent 999c345b93
commit 0e8fd182de
+7
View File
@@ -462,6 +462,13 @@ mjModel* mj_makeModel(int nq, int nv, int nu, int na, int nbody, int njnt,
MJMODEL_INTS;
#undef X
// nbody should always be positive
if (m->nbody == 0) {
mju_warning("Invalid model: nbody == 0");
mj_deleteModel(m);
return 0;
}
// compute buffer size
m->nbuffer = 0;
#define X(type, name, nr, nc) \