From: Øyvind Kolås Date: Fri, 10 Nov 2017 09:44:21 +0000 (+0100) Subject: extensions: protect another conversion against /0.0 X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~21^2~56 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c411c717d5c9f4944b4419434e1b83979b4720cb;p=babl.git extensions: protect another conversion against /0.0 --- diff --git a/extensions/gggl.c b/extensions/gggl.c index d101bef..cf83988 100644 --- a/extensions/gggl.c +++ b/extensions/gggl.c @@ -560,10 +560,16 @@ conv_rgbA16_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst { float alpha = (((unsigned short *) src)[3]) / 65535.0; int c; + float recip_alpha; + + if (alpha == 0.0f) + recip_alpha = 10000.0; + else + recip_alpha = 1.0/alpha; for (c = 0; c < 3; c++) { - (*(float *) dst) = (*(unsigned short *) src / 65535.0) / alpha; + (*(float *) dst) = (*(unsigned short *) src / 65535.0) * recip_alpha; dst += 4; src += 2; }