Commit: ab85c5f980533cc9570acc015ec66cb49fc25908
Author: Bastien Montagne
Date:   Sat Jun 27 09:46:38 2015 +0200
Branches: master
https://developer.blender.org/rBab85c5f980533cc9570acc015ec66cb49fc25908

Fix crasher when loading multiview OpenEXR image.

With multiview/multilayer OpenEXR file, `load_image_single()` will return NULL 
ibuf,
since it has already populated ima (with `image_create_multiview()` or
`image_create_multilayer()` calls).

Also, added some more checks before doing `IMB_ImBufFromStereo3d()`, to be sure
we do have enough slots in ibuf_arr, and we do not overwrite second ibuf either.

===================================================================

M       source/blender/blenkernel/intern/image.c

===================================================================

diff --git a/source/blender/blenkernel/intern/image.c 
b/source/blender/blenkernel/intern/image.c
index 451ab43..3cc5905 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -3503,16 +3503,20 @@ static ImBuf *image_load_image_file(Image *ima, 
ImageUser *iuser, int cfra)
                const size_t totviews = BLI_listbase_count(&ima->views);
                BLI_assert(totviews > 0);
 
-               ibuf_arr = MEM_mallocN(sizeof(ImBuf *) * totviews, "Image Views 
Imbufs");
+               ibuf_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Image Views 
Imbufs");
 
                for (i = 0; i < totfiles; i++)
                        ibuf_arr[i] = load_image_single(ima, iuser, cfra, i, 
has_packed, &assign);
 
-               if ((ima->flag & IMA_IS_STEREO) && ima->views_format == 
R_IMF_VIEWS_STEREO_3D)
+               /* multi-views/multi-layers OpenEXR files directly populate 
ima, and return NULL ibuf... */
+               if ((ima->flag & IMA_IS_STEREO) && ima->views_format == 
R_IMF_VIEWS_STEREO_3D &&
+                   ibuf_arr[0] && totfiles == 1 && totviews >= 2)
+               {
                        IMB_ImBufFromStereo3d(ima->stereo3d_format, 
ibuf_arr[0], &ibuf_arr[0], &ibuf_arr[1]);
+               }
 
                /* return the original requested ImBuf */
-               i = iuser && iuser->multi_index < totviews ? iuser->multi_index 
: 0;
+               i = (iuser && iuser->multi_index < totviews) ? 
iuser->multi_index : 0;
                ibuf = ibuf_arr[i];
 
                if (assign) {

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to