Validate the MjModel pointer passed to MjData constructor.
Fixes #2426. PiperOrigin-RevId: 785411895 Change-Id: If698120b5a4ab4ac457d35760380c140b1b5a208
This commit is contained in:
committed by
Copybara-Service
parent
8b94bd0ef6
commit
60f9b34a77
@@ -728,7 +728,12 @@ This is useful for example when the MJB is not available as a file on disk.)"));
|
|||||||
|
|
||||||
// ==================== MJDATA ===============================================
|
// ==================== MJDATA ===============================================
|
||||||
py::class_<MjDataWrapper> mjData(m, "MjData");
|
py::class_<MjDataWrapper> mjData(m, "MjData");
|
||||||
mjData.def(py::init<MjModelWrapper*>());
|
mjData.def(py::init([](MjModelWrapper* m) {
|
||||||
|
if (!m) {
|
||||||
|
throw py::type_error("MjModel cannot be None");
|
||||||
|
}
|
||||||
|
return MjDataWrapper(m);
|
||||||
|
}));
|
||||||
mjData.def_property_readonly("_address", [](const MjDataWrapper& d) {
|
mjData.def_property_readonly("_address", [](const MjDataWrapper& d) {
|
||||||
return reinterpret_cast<std::uintptr_t>(d.get());
|
return reinterpret_cast<std::uintptr_t>(d.get());
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user