Sensor plugin parsing: Ensure sensor reftype is only assigned if a value in the XML exists.
PiperOrigin-RevId: 495314131 Change-Id: I5f955c435474de1dd1d75f7a7492e3a21ea9d289
This commit is contained in:
committed by
Copybara-Service
parent
05216f183c
commit
bc02c2455e
@@ -3186,8 +3186,9 @@ void mjXReader::Sensor(XMLElement* section) {
|
||||
if (psen->objtype == mjOBJ_UNKNOWN && !psen->objname.empty()) {
|
||||
throw mjXError(elem, "objname is specified but objtype is not");
|
||||
}
|
||||
ReadAttrTxt(elem, "reftype", text);
|
||||
psen->reftype = (mjtObj)mju_str2Type(text.c_str());
|
||||
if (ReadAttrTxt(elem, "reftype", text)) {
|
||||
psen->reftype = (mjtObj)mju_str2Type(text.c_str());
|
||||
}
|
||||
ReadAttrTxt(elem, "refname", psen->refname);
|
||||
if (psen->reftype != mjOBJ_UNKNOWN && psen->refname.empty()) {
|
||||
throw mjXError(elem, "reftype is specified but refname is not");
|
||||
|
||||
Reference in New Issue
Block a user