diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-06-27 10:46:38 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-06-27 11:24:54 +0300 |
commit | ab85c5f980533cc9570acc015ec66cb49fc25908 (patch) | |
tree | 3a49314c4288bd7746fe6203b1675e39e1c3e09c /source/blender | |
parent | 851d7535d9711af8b0d42cb08d7ecdb281d63604 (diff) |
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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 451ab43367b..3cc5905e763 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) { |