Fix null pointer deref for unknown class names.
PiperOrigin-RevId: 610391077 Change-Id: I5abd62ff46e31e788f06fe111adb3c25287d4fdc
This commit is contained in:
committed by
Copybara-Service
parent
b47d97652e
commit
8679c9fc59
@@ -346,6 +346,18 @@ mjmDefault* mjm_getDefault(mjElement element) {
|
||||
|
||||
|
||||
|
||||
// find default in model by class name
|
||||
mjmDefault* mjm_findDefault(mjmModel* modelspec, const char* classname) {
|
||||
mjCModel* model = reinterpret_cast<mjCModel*>(modelspec->element);
|
||||
mjCDef* cdef = model->FindDef(classname);
|
||||
if (!cdef) {
|
||||
return nullptr;
|
||||
}
|
||||
return &cdef->spec;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// find body in model by name
|
||||
mjmBody* mjm_findBody(mjmModel* modelspec, const char* name) {
|
||||
mjCModel* model = reinterpret_cast<mjCModel*>(modelspec->element);
|
||||
|
||||
Reference in New Issue
Block a user