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

Test return value of extractSHRT to avoid uninitialized reference #261

Merged

Conversation

cary-ilm
Copy link
Member

@cary-ilm cary-ilm commented Jun 2, 2022

If extractSHRT failes in computeRSMatrix, it's an error, so throw.

If extractSHRT fails in testMatrix in testExtractSHRT.cpp, it's fatal. The test was present for testMatrix(M33f) but missing for testMatrix(M44f). This lead to an uninitialized memory refererence since the failure leaves the arguments uninitialized.

Signed-off-by: Cary Phillips cary@ilm.com

If extractSHRT failes in computeRSMatrix, it's an error, so throw.

If extractSHRT fails in testMatrix in testExtractSHRT.cpp, it's
fatal. The test was present for testMatrix(M33f) but missing for
testMatrix(M44f). This lead to an uninitialized memory refererence
since the failure leaves the arguments uninitialized.

Signed-off-by: Cary Phillips <cary@ilm.com>
Copy link
Contributor

@meshula meshula left a comment

Choose a reason for hiding this comment

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

It's sort of peculiar that this is one of the few functions in this header that don't have the bool exc = true argument to control whether an exception is thrown. This isn't a change request, just an idle observation.

@cary-ilm
Copy link
Member Author

cary-ilm commented Jun 2, 2022

Yes, I noted the same thing. For consistency, adding that might be a preferable solution, but at this point it's probably best to just leave the API as is. It's a pretty obscure function, I doubt it's used widely.

@cary-ilm cary-ilm merged commit 3ad5d4d into AcademySoftwareFoundation:main Jun 2, 2022
cary-ilm added a commit to cary-ilm/Imath that referenced this pull request Oct 31, 2022
…ademySoftwareFoundation#261)

If extractSHRT failes in computeRSMatrix, it's an error, so throw.

If extractSHRT fails in testMatrix in testExtractSHRT.cpp, it's
fatal. The test was present for testMatrix(M33f) but missing for
testMatrix(M44f). This lead to an uninitialized memory refererence
since the failure leaves the arguments uninitialized.

Signed-off-by: Cary Phillips <cary@ilm.com>
cary-ilm added a commit that referenced this pull request Nov 3, 2022
If extractSHRT failes in computeRSMatrix, it's an error, so throw.

If extractSHRT fails in testMatrix in testExtractSHRT.cpp, it's
fatal. The test was present for testMatrix(M33f) but missing for
testMatrix(M44f). This lead to an uninitialized memory refererence
since the failure leaves the arguments uninitialized.

Signed-off-by: Cary Phillips <cary@ilm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants