From 8a617ee3ae814fabdb526d5a7763764a2c88c736 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 26 Mar 2015 18:55:48 +0000 Subject: Avoid division by 0 in blend calls. If b is out of range (-ve), then this can let s == 0 and we can get failures. --- source/fitz/draw-blend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/fitz/draw-blend.c b/source/fitz/draw-blend.c index ea5d30bc..57aa28b1 100644 --- a/source/fitz/draw-blend.c +++ b/source/fitz/draw-blend.c @@ -75,7 +75,7 @@ static inline int fz_lighten_byte(int b, int s) static inline int fz_color_dodge_byte(int b, int s) { s = 255 - s; - if (b == 0) + if (b <= 0) return 0; else if (b >= s) return 255; @@ -86,7 +86,7 @@ static inline int fz_color_dodge_byte(int b, int s) static inline int fz_color_burn_byte(int b, int s) { b = 255 - b; - if (b == 0) + if (b <= 0) return 255; else if (b >= s) return 0; -- cgit v1.2.3