about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2024-03-09 21:05:32 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2024-03-09 21:05:32 +0000
commit62ee2845e8eb1c42ba1935ecaeb015f14cd4700a (patch)
treebb18e989590e4311fff9653273ffe944ce9e6552
parentc6a2fe43dfaec00b428ca3e09dfa2f61ba2c4727 (diff)
downloadnetpbm-mirror-62ee2845e8eb1c42ba1935ecaeb015f14cd4700a.tar.gz
netpbm-mirror-62ee2845e8eb1c42ba1935ecaeb015f14cd4700a.tar.xz
netpbm-mirror-62ee2845e8eb1c42ba1935ecaeb015f14cd4700a.zip
Fix where extracted rectangle is entirely below the input image in PBM fast path
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4865 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY9
-rw-r--r--editor/pamcut.c2
2 files changed, 10 insertions, 1 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index f0b813d4..e7525682 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -8,6 +8,15 @@ not yet  BJH  Release 11.06.00
 
               pamcut: add -reportonly.
 
+              pamcut: fix incorrect output when rectangle to cut is entirely
+              above the input image.  Invisible junk after image.  Always
+              broken.  (The ability to cut outside the input image was new in
+              pamcut's predecessor pnmcut in Netpbm 9.7 (August 2000).
+
+              pamcut: fix incorrect output with PBM input when rectangle to
+              cut is entirely below the input image.  Invisible junk after
+              image.  Broken in Netpbm 10.44 (September 2008).
+
               ppmtowinicon: fix array overrun with 4 and 8 bits per pixel.
               Broken in Netpbm 11.05 (December 2023).
 
diff --git a/editor/pamcut.c b/editor/pamcut.c
index c495c11b..31b44f81 100644
--- a/editor/pamcut.c
+++ b/editor/pamcut.c
@@ -784,7 +784,7 @@ extractRowsPbm(const struct pam * const inpamP,
 
     /* Write out bottom padding */
     makeBlackPbmRow(bitrow, outpamP->width);
-    for (; row < bottomrow+1; ++row)
+    for (row = MAX(inpamP->height, toprow); row < bottomrow+1; ++row)
         pbm_writepbmrow_packed(outpamP->file, bitrow, outpamP->width, 0);
 
     pbm_freerow_packed(bitrow);