[babl] extensions: protect gray unpremuls from gggl against division by 0.0
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] extensions: protect gray unpremuls from gggl against division by 0.0
- Date: Fri, 10 Nov 2017 09:35:43 +0000 (UTC)
commit 805c7d12ce5cad221551ae4a2801d6297263b5fe
Author: Øyvind Kolås <pippin gimp org>
Date: Fri Nov 10 10:34:57 2017 +0100
extensions: protect gray unpremuls from gggl against division by 0.0
extensions/gggl-lies.c | 5 ++++-
extensions/gggl.c | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/extensions/gggl-lies.c b/extensions/gggl-lies.c
index b34f8ef..c08dccd 100644
--- a/extensions/gggl-lies.c
+++ b/extensions/gggl-lies.c
@@ -356,7 +356,10 @@ conv_gAF_gaF (const Babl *conversion,unsigned char *src, unsigned char *dst, lon
{
float alpha = (*(float *) (src + 4));
- *(float *) dst = ((*(float *) src) / alpha);
+ if (alpha == 0.0f)
+ *(float *) dst = 0.0f;
+ else
+ *(float *) dst = ((*(float *) src) / alpha);
dst += 4;
src += 4;
*(float *) dst = alpha;
diff --git a/extensions/gggl.c b/extensions/gggl.c
index 83352d2..d101bef 100644
--- a/extensions/gggl.c
+++ b/extensions/gggl.c
@@ -373,7 +373,10 @@ conv_gAF_gaF (const Babl *conversion,unsigned char *src, unsigned char *dst, lon
{
float alpha = (*(float *) (src + 4));
- *(float *) dst = ((*(float *) src) / alpha);
+ if (alpha == 0.0f)
+ *(float *) dst = 0.0f;
+ else
+ *(float *) dst = ((*(float *) src) / alpha);
dst += 4;
src += 4;
*(float *) dst = alpha;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]