[gs-commits] ghostpdl branch, gs9.28-temp-for-testing, updated. gs9.28-temp-for-testing-tag-11-gdccf380

[email protected] (Robin Watts)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, gs9.28-temp-for-testing has been updated
       via  dccf380bb7bcc6b65e35b6b19d8993f7a5666301 (commit)
      from  f755da3d792390187244c329c16a183ef7aa1487 (commit)

----------------------------------------------------------------------
commit dccf380bb7bcc6b65e35b6b19d8993f7a5666301
Author: Robin Watts <[email protected]>
Date:   Wed Aug 28 12:50:36 2019 +0100

    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.

diff --git a/base/gxshade6.c b/base/gxshade6.c
index 11fe3cc..41ab5ad 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));


Summary of changes:
 base/gxshade6.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.