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
|
||||
|
||||
@@ -117,8 +117,8 @@ mjSpec* mju_decodeResource(mjResource* resource, const char* content_type, const
|
||||
decoder = mjp_findDecoder(resource, mjuu_extToContentType(resource->name).c_str());
|
||||
}
|
||||
if (!decoder) {
|
||||
mju_error("Could not find decoder for resource '%s'", resource->name);
|
||||
mju_warning("Could not find decoder for resource '%s'", resource->name);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return decoder->decode(resource, vfs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user