about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2008-09-17 02:31:55 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2008-09-17 02:31:55 +0000
commitc92fd8c64782d83d4b08f35c370578cd01cfa9f1 (patch)
tree4dad1826f4873fa3f134c8fc828c842662411b88
parent346774c389571825d7bfbd5b2a065a70c7b02fe5 (diff)
downloadnetpbm-mirror-c92fd8c64782d83d4b08f35c370578cd01cfa9f1.tar.gz
netpbm-mirror-c92fd8c64782d83d4b08f35c370578cd01cfa9f1.tar.xz
netpbm-mirror-c92fd8c64782d83d4b08f35c370578cd01cfa9f1.zip
Fix crash when line is completely out of frame
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@727 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY3
-rw-r--r--lib/libppmd.c8
2 files changed, 11 insertions, 0 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index 4595baca..8841c018 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -18,6 +18,9 @@ not yet  BJH  Release 10.44.00
 
               pnmpaste: fail if user specified stdin for both images.
 
+              libppmd/ppmdraw: fix crash when line is completely out of
+              frame.
+
               pamgradient: fix bug: always produces color, not grayscale.
 
               pnm_backgroundxel(), pnm_backgroundxelrow() (affects
diff --git a/lib/libppmd.c b/lib/libppmd.c
index 167d5c76..1046ce68 100644
--- a/lib/libppmd.c
+++ b/lib/libppmd.c
@@ -260,6 +260,14 @@ clipEnd0(int    const x0,
         }
     }
 
+    /* Clipping vertically may have moved the endpoint out of frame
+       horizontally.  If so, we know the other endpoint is also out of
+       frame horizontally and the line misses the frame entirely.
+    */
+    if (cx0 < 0 || cx0 >= cols) {
+        assert(x1 < 0 || x1 >= cols);
+        noLine = TRUE;
+    }
     *cx0P = cx0;
     *cy0P = cy0;
     *noLineP = noLine;