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

GlfImage::OpenForReading not guarded against exceptions #202

Open
meshula opened this issue Apr 18, 2017 · 1 comment
Open

GlfImage::OpenForReading not guarded against exceptions #202

meshula opened this issue Apr 18, 2017 · 1 comment

Comments

@meshula
Copy link
Member

meshula commented Apr 18, 2017

GlfImage::OpenForReading attempts to open an image file for reading, and if it's not possible, it returns an empty pointer.

On the other hand, if one of the libraries OIIO uses to open a file throws an exception, it will be unhandled by OIIO, glf, hydra, or usdImagingGL (gazing up the call stack), and throw all the way out to the running application where there's no reasonable way to respond to the exception. Since not loading was already deemed non-fatal by OpenForReading, I think an exception from a loading library should also be treated as non-fatal.

If the call to _OpenForReading were guarded here with a try { } catch(...) { return GlfImageSharedPtr(); } the behavior would be more consistent.

GlfImageSharedPtr
GlfImage::OpenForReading(std::string const & filename, int subimage)
{
    GlfImageRegistry & registry = GlfImageRegistry::GetInstance();

    GlfImageSharedPtr image = registry._ConstructImage(filename);
    if (!image || !image->_OpenForReading(filename, subimage)) {
        return GlfImageSharedPtr();
    }

    return image;
}

@jtran56
Copy link

jtran56 commented Apr 18, 2017

Filed as internal issue #145448.

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

No branches or pull requests

2 participants