summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2010-08-23 16:30:12 +0000
committerTor Andersson <tor@ghostscript.com>2010-08-23 16:30:12 +0000
commitf0cdbba1116e02efb38de2b3a976489cb57d5491 (patch)
treeb6ccfe27bbfa53e4b699d14434de75e340539643
parentb7d3d02e3e213ab9252badc93eb57809bdaee16a (diff)
downloadmupdf-f0cdbba1116e02efb38de2b3a976489cb57d5491.tar.xz
Guard against divide-by-zero in stitched function evaluations where the bounds for an entry are zero-sized.
-rw-r--r--mupdf/pdf_function.c10
1 files 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 };