From 5354998a215ec1900ec401ecdb01aae61fa02f5e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Feb 2013 14:58:58 +0000 Subject: [PATCH] Fix #34213: crash loading openexr multilayer with use alpha disabled. --- source/blender/imbuf/intern/rectop.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index d2b0645cf93..cae705ae798 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -594,11 +594,17 @@ void IMB_rectfill_area(struct ImBuf *ibuf, const float col[4], int x1, int y1, i void IMB_rectfill_alpha(ImBuf *ibuf, const float value) { int i; + if (ibuf->rect_float) { - float *fbuf = ibuf->rect_float + 3; + float *fbuf; + + if (ibuf->channels != 4) return; + + fbuf = ibuf->rect_float + 3; for (i = ibuf->x * ibuf->y; i > 0; i--, fbuf += 4) { *fbuf = value; } } - else { + + if (ibuf->rect) { const unsigned char cvalue = value * 255; unsigned char *cbuf = ((unsigned char *)ibuf->rect) + 3; for (i = ibuf->x * ibuf->y; i > 0; i--, cbuf += 4) { *cbuf = cvalue; }