Correctly validate the size of user sensors in mj_validateReference.

PiperOrigin-RevId: 494877162
Change-Id: I0a070d7813efea6216d15270f62b6009c55e1a54
This commit is contained in:
Nimrod Gileadi
2022-12-12 17:48:23 -08:00
committed by Copybara-Service
parent 21f10ce1b6
commit 7076da6909
2 changed files with 22 additions and 3 deletions
+19
View File
@@ -434,6 +434,25 @@ TEST_F(ValidateReferencesTest, SensorsAddress) {
}
}
TEST_F(ValidateReferencesTest, SensorsAddressUser) {
static const char xml[] = R"(
<mujoco>
<sensor>
<user dim="3" user="1 2 3 4 5" />
<user dim="2" />
<user dim="1" />
</sensor>
</mujoco>
)";
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
ASSERT_THAT(model, NotNull()) << "Failed to load model: " << error.data();
EXPECT_THAT(mj_validateReferences(model), IsNull());
mj_deleteModel(model);
}
TEST_F(ValidateReferencesTest, SensorsObj) {
static const char xml[] = R"(
<mujoco>