about summary refs log tree commit diff
diff options
context:
space:
mode:
-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);