USD import: invalid UsdUVTexture input crash.

Fixed crash when accessing invalud texture file
inputs.
This commit is contained in:
Michael Kowalski 2022-08-14 15:58:02 -04:00
parent a61fdcd349
commit 3f3910966a
1 changed files with 6 additions and 6 deletions

View File

@ -719,6 +719,12 @@ void USDMaterialReader::load_tex_image(const pxr::UsdShadeShader &usd_shader,
/* Try to load the texture image. */
pxr::UsdShadeInput file_input = usd_shader.GetInput(usdtokens::file);
if (!file_input) {
std::cerr << "WARNING: Couldn't get file input for USD shader " << usd_shader.GetPath()
<< std::endl;
return;
}
/* File input may have a connected source, e.g., if it's been overridden by
* an input on the mateial. */
if (file_input.HasConnectedSource()) {
@ -735,12 +741,6 @@ void USDMaterialReader::load_tex_image(const pxr::UsdShadeShader &usd_shader,
}
}
if (!file_input) {
std::cerr << "WARNING: Couldn't get file input for USD shader " << usd_shader.GetPath()
<< std::endl;
return;
}
pxr::VtValue file_val;
if (!file_input.Get(&file_val) || !file_val.IsHolding<pxr::SdfAssetPath>()) {
std::cerr << "WARNING: Couldn't get file input value for USD shader " << usd_shader.GetPath()