From 258dfc2275e0e337e279313b0528e58ef1328fd0 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Fri, 31 Aug 2018 13:01:27 +0200 Subject: [PATCH] Fix segfault when loading 16-bit float tiff --- rtengine/imagefloat.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rtengine/imagefloat.h b/rtengine/imagefloat.h index ee719a352..65c291775 100644 --- a/rtengine/imagefloat.h +++ b/rtengine/imagefloat.h @@ -153,7 +153,8 @@ public: if (exponent == 0) { if (mantissa == 0) { // Plus or minus zero - return (uint32_t) (sign << 31); + tmp.i = (uint32_t) (sign << 31); + return tmp.f; } else { // Denormalized number -- renormalize it while (!(mantissa & 0x00000400)) { @@ -165,8 +166,9 @@ public: } } else if (exponent == 31) { if (mantissa == 0) { - // Positive or negative infinity, convert to maximum (16 bit) values. - return (uint32_t) ((sign << 31) | ((0x1eL + 127 - 15) << 23) | (0x3ffL << 13)); + // Positive or negative infinity, convert to maximum (16 bit) values. + tmp.i = (uint32_t)((sign << 31) | ((0x1eL + 127 - 15) << 23) | (0x3ffL << 13)); + return tmp.f; } else { // Nan -- Just set to zero. return 0;