summaryrefslogtreecommitdiff
path: root/base/gxshade6.c
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2019-08-28 12:50:36 +0100
committerRobin Watts <Robin.Watts@artifex.com>2019-08-28 12:52:02 +0100
commitf531552c99a04f003412f7a83d4661e927f88d40 (patch)
tree980246139f863efe8d724055505eb467d8b269b7 /base/gxshade6.c
parent25f7cb4da347610dd49bd8001746605f1a29caa8 (diff)
downloadghostpdl-f531552c99a04f003412f7a83d4661e927f88d40.tar.gz
Bug 701446: Avoid divide by zero in shading.
The previous commit for this bug was enough to solve the problem for ppmraw, but not, it seems, for other devices. This addresses the division by zero more directly.
Diffstat (limited to 'base/gxshade6.c')
-rw-r--r--base/gxshade6.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/base/gxshade6.c b/base/gxshade6.c
index 11fe3ccad..41ab5adc5 100644
--- a/base/gxshade6.c
+++ b/base/gxshade6.c
@@ -1025,12 +1025,15 @@ gx_shade_trapezoid(patch_fill_state_t *pfs, const gs_fixed_point q[4],
re.start.y = ybot;
re.end.y = ytop;
}
- /* Now, check whether the left and right edges cross. This can
- * only happen (for well formed input) in the case where one of
- * the edges was completely out of range and has now been pulled
- * in to the edge of the clip region. */
+ /* Now, check whether the left and right edges cross. Previously
+ * this comment said: "This can only happen (for well formed
+ * input) in the case where one of the edges was completely out
+ * of range and has now been pulled in to the edge of the clip
+ * region." I now do not believe this to be true. */
if (le.start.x > re.start.x) {
if (le.start.x == le.end.x) {
+ if (re.start.x == re.end.x)
+ return 0;
ybot += (fixed)((int64_t)(re.end.y-re.start.y)*
(int64_t)(le.start.x-re.start.x)/
(int64_t)(re.end.x-re.start.x));
@@ -1048,6 +1051,8 @@ gx_shade_trapezoid(patch_fill_state_t *pfs, const gs_fixed_point q[4],
}
if (le.end.x > re.end.x) {
if (le.start.x == le.end.x) {
+ if (re.start.x == re.end.x)
+ return 0;
ytop -= (fixed)((int64_t)(re.end.y-re.start.y)*
(int64_t)(le.end.x-re.end.x)/
(int64_t)(re.start.x-re.end.x));