about summary refs log tree commit diff
path: root/editor/pamcut.c
diff options
context:
space:
mode:
Diffstat (limited to 'editor/pamcut.c')
-rw-r--r--editor/pamcut.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/editor/pamcut.c b/editor/pamcut.c
index 76a57f8e..ce63da7b 100644
--- a/editor/pamcut.c
+++ b/editor/pamcut.c
@@ -658,7 +658,8 @@ cutOneImage(FILE *             const ifP,
 
     pnm_writepaminit(&outpam);
 
-    if (PNM_FORMAT_TYPE(outpam.format) == PBM_TYPE)
+    if (PNM_FORMAT_TYPE(outpam.format) == PBM_TYPE &&
+        leftcol >= 0 && rightcol < inpam.width)
         extractRowsPBM(&inpam, &outpam, leftcol, rightcol, toprow, bottomrow);
     else
         extractRowsGen(&inpam, &outpam, leftcol, rightcol, toprow, bottomrow);