diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-08-23 16:30:12 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-08-23 16:30:12 +0000 |
commit | f0cdbba1116e02efb38de2b3a976489cb57d5491 (patch) | |
tree | b6ccfe27bbfa53e4b699d14434de75e340539643 | |
parent | b7d3d02e3e213ab9252badc93eb57809bdaee16a (diff) | |
download | mupdf-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.c | 10 |
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 }; |