Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent invalid binding relationship access in UsdShadeMaterialBindingAPI #2024

Conversation

tkchanat
Copy link

@tkchanat tkchanat commented Sep 6, 2022

Description of Change(s)

The validity of the binding relationship is not verified before accessing the stage, which then throws a Usd_ThrowExpiredPrimAccessError while dereferencing the prim data handle. Adding an extra check in the if-condition prevents such invalid access and returns an empty material if the binding relationship is invalid.

  • I have submitted a signed Contributor License Agreement

@@ -252,7 +252,7 @@ UsdShadeMaterialBindingAPI::DirectBinding::DirectBinding(
UsdShadeMaterial
UsdShadeMaterialBindingAPI::DirectBinding::GetMaterial() const
{
if (!_materialPath.IsEmpty()) {
if (_bindingRel && !_materialPath.IsEmpty()) {
Copy link
Member

@spiffmon spiffmon Sep 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @tkchanat ! Can you change this pattern to if (_bindingRel.GetPrim() ... ? It is sufficient, and cheaper than a full Relationship validity test. Thank you!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @spiffmon! I changed the pattern in the latest commit and it's looking good now.

@tallytalwar
Copy link
Contributor

Filed as internal issue #USD-7614

@pixar-oss pixar-oss merged commit 7c8585a into PixarAnimationStudios:dev Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants