From f0cdbba1116e02efb38de2b3a976489cb57d5491 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 23 Aug 2010 16:30:12 +0000 Subject: Guard against divide-by-zero in stitched function evaluations where the bounds for an entry are zero-sized. --- mupdf/pdf_function.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mupdf/pdf_function.c b/mupdf/pdf_function.c index 603759e1..a7e26e24 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 }; -- cgit v1.2.3