Fix T50968: Cycles crashes when image datablock points to a directory

See more details about root of the cause there:

  https://github.com/OpenImageIO/oiio/pull/1640
This commit is contained in:
Sergey Sharybin 2017-03-17 14:47:12 +01:00
parent d6b4fb6429
commit ea3d7a7f58
Notes: blender-bot 2023-02-14 07:08:25 +01:00
Referenced by issue #50968, linux official build glibc 219 crash
1 changed files with 15 additions and 0 deletions

View File

@ -156,6 +156,16 @@ ImageManager::ImageDataType ImageManager::get_image_metadata(const string& filen
}
}
/* Perform preliminary checks, with meaningful logging. */
if(!path_exists(filename)) {
VLOG(1) << "File '" << filename << "' does not exist.";
return IMAGE_DATA_TYPE_BYTE4;
}
if(path_is_directory(filename)) {
VLOG(1) << "File '" << filename << "' is a directory, can't use as image.";
return IMAGE_DATA_TYPE_BYTE4;
}
ImageInput *in = ImageInput::create(filename);
if(in) {
@ -432,6 +442,11 @@ bool ImageManager::file_load_image_generic(Image *img, ImageInput **in, int &wid
return false;
if(!img->builtin_data) {
/* NOTE: Error logging is done in meta data acquisition. */
if(!path_exists(img->filename) || path_is_directory(img->filename)) {
return false;
}
/* load image from file through OIIO */
*in = ImageInput::create(img->filename);