[gs-commits] mupdf/master - 0_6-277-ga939ba3 - Guard against divide-by-zero in stitched function evaluations where the bounds for an entry are zero-sized.

Tor Andersson tor at ghostscript.com
Mon Aug 23 16:36:56 UTC 2010


commit a939ba3f98eaf3ab58f9388c6d694b82bb6fac36
Author: Tor Andersson <tor at ghostscript.com>
Date:   Mon Aug 23 16:30:12 2010 +0000

    Guard against divide-by-zero in stitched function evaluations where the bounds for an entry are zero-sized.
    
    Ignore-this: c4a89719063e8682c077d769bf5e49a6
    
    darcs-hash:20100823163012-f546f-96d9d47a7237362ac324e1543911760cbb306dbc.gz

 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/mupdf/pdf_function.c b/mupdf/pdf_function.c
index 603759e..a7e26e2 100644
--- a/mupdf/pdf_function.c
+++ b/mupdf/pdf_function.c
@@ -65,8 +65,14 @@ struct pdf_function_s
 
 #define RADIAN 57.2957795
 
-#define LERP(x, xmin, xmax, ymin, ymax) \
-	(ymin) + ((x) - (xmin)) * ((ymax) - (ymin)) / ((xmax) - (xmin))
+static inline float LERP(float x, float xmin, float xmax, float ymin, float ymax)
+{
+	if (xmin == xmax)
+		return ymin;
+	if (ymin == ymax)
+		return ymin;
+	return ymin + (x - xmin) * (ymax - ymin) / (xmax - xmin);
+}
 
 enum { PSBOOL, PSINT, PSREAL, PSOPERATOR, PSBLOCK };
 

--
git/hooks/post-receive


More information about the gs-commits mailing list