diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-05-04 13:25:09 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-05-04 13:25:09 +0400 |
commit | 2823a9a8090c9d063b0d35412266bac2e6cba7c8 (patch) | |
tree | c1d6ec8d38173ff13f35193abf16f656868ce86b /source/blender | |
parent | 549b3ccba1da9d5b106f7c4699c9cf63fb609662 (diff) |
Fix #31286: saving 16 bit BW tiff could crash due to invalid memory access. Also
found that 16 bit RGBA saving was not working, fixed as well.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/imbuf/intern/tiff.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 2a7ba2cae26..a9396a5824d 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -778,22 +778,17 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) if (pixels16) { /* convert from float source */ - float rgb[3]; + float rgb[4]; if (ibuf->profile == IB_PROFILE_LINEAR_RGB) linearrgb_to_srgb_v3_v3(rgb, &fromf[from_i]); else copy_v3_v3(rgb, &fromf[from_i]); - to16[to_i+0] = FTOUSHORT(rgb[0]); - to16[to_i+1] = FTOUSHORT(rgb[1]); - to16[to_i+2] = FTOUSHORT(rgb[2]); - to_i += 3; from_i+=3; - - if (samplesperpixel == 4) { - to16[to_i+3] = FTOUSHORT(fromf[from_i+3]); - /*to_i++; from_i++;*/ /*unused, set on each loop */ - } + rgb[3] = fromf[from_i+3]; + + for (i = 0; i < samplesperpixel; i++, to_i++) + to16[to_i] = FTOUSHORT(rgb[i]); } else { for (i = 0; i < samplesperpixel; i++, to_i++, from_i++) |