Make missing decoder non-failing.
Otherwise, if you try to open a random file in studio, it will crash. PiperOrigin-RevId: 865372002 Change-Id: I96d3121b6de792daaff53155ea2436ac3f6668db
This commit is contained in:
committed by
Copybara-Service
parent
1a9ca3239a
commit
1a0fe29c41
@@ -126,7 +126,14 @@ mjSpec* mj_parse(const char* filename, const char* content_type,
|
||||
memcpy(resource->name, fullname.c_str(), sizeof(char) * (n + 1));
|
||||
}
|
||||
|
||||
return mju_decodeResource(resource, content_type, vfs);
|
||||
mjSpec* spec = mju_decodeResource(resource, content_type, vfs);
|
||||
if (spec == nullptr) {
|
||||
if (error) {
|
||||
strncpy(error, "could not decode content", error_sz);
|
||||
error[error_sz - 1] = '\0';
|
||||
}
|
||||
}
|
||||
return spec;
|
||||
}
|
||||
|
||||
// compile model
|
||||
|
||||
Reference in New Issue
Block a user