[babl] extensions: protect another conversion against /0.0



commit c411c717d5c9f4944b4419434e1b83979b4720cb
Author: Øyvind Kolås <pippin gimp org>
Date:   Fri Nov 10 10:44:21 2017 +0100

    extensions: protect another conversion against /0.0

 extensions/gggl.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
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;
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]