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
@@ -31,8 +31,8 @@
|
||||
|
||||
#include <mujoco/mjmodel.h>
|
||||
#include <mujoco/mjplugin.h>
|
||||
#include <mujoco/mjvisualize.h>
|
||||
#include <mujoco/mjtnum.h>
|
||||
#include <mujoco/mjvisualize.h>
|
||||
#include "engine/engine_plugin.h"
|
||||
#include "engine/engine_util_errmem.h"
|
||||
#include "engine/engine_util_misc.h"
|
||||
@@ -3986,12 +3986,14 @@ void mjXReader::Keyframe(XMLElement* section) {
|
||||
// get defaults class
|
||||
mjmDefault* mjXReader::GetClass(XMLElement* section) {
|
||||
string text;
|
||||
mjmDefault* def = 0;
|
||||
mjmDefault* def = nullptr;
|
||||
|
||||
if (ReadAttrTxt(section, "class", text)) {
|
||||
def = &model->FindDef(text)->spec;
|
||||
def = mjm_findDefault(&model->spec, text.c_str());
|
||||
if (!def) {
|
||||
throw mjXError(section, "unknown default class");
|
||||
throw mjXError(
|
||||
section,
|
||||
std::string("unknown default class name '" + text + "'").c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user