about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-09-08 00:46:04 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-09-08 00:46:04 +0000
commitb3c523f23f5c7e3777d0cbb4094737da84b0fa90 (patch)
tree23f0534b7d57d1d7486a33503af06fdde35b0089
parentdaa072c5aaf1a04922396943dc312b6ac2d9faf1 (diff)
downloadnetpbm-mirror-b3c523f23f5c7e3777d0cbb4094737da84b0fa90.tar.gz
netpbm-mirror-b3c523f23f5c7e3777d0cbb4094737da84b0fa90.tar.xz
netpbm-mirror-b3c523f23f5c7e3777d0cbb4094737da84b0fa90.zip
Fix crash with -compare of BLACKANDWHITE PAMs
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3954 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY4
-rw-r--r--other/pamarith.c7
2 files changed, 8 insertions, 3 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index fd0113be..5b06e3dd 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -31,8 +31,8 @@ not yet  BJH  Release 10.92.00
               jpeg2ktopam: Fix crash whenever the program fails.  Broken in
               Netpbm 10.42 (March 2008).
 
-              pamarith: Fix crash with -compare where inputs are PBM.  Broken
-              in Netpbm 10.14 (February 2003).
+              pamarith: Fix crash with -compare where inputs are PBM or
+              BLACKANDWHITE PAM.  Broken in Netpbm 10.14 (February 2003).
 
               pamfunc: Fix crash with -changemaxval and PBM or BLACKANDWHITE
               PAM input.  Always broken.  -changemaxval was new in Netpbm
diff --git a/other/pamarith.c b/other/pamarith.c
index 12c102b3..c67c7326 100644
--- a/other/pamarith.c
+++ b/other/pamarith.c
@@ -4,6 +4,7 @@
 
 #include "pm_c_util.h"
 #include "mallocvar.h"
+#include "nstring.h"
 #include "shhopt.h"
 #include "pam.h"
 
@@ -289,7 +290,11 @@ computeOutputType(struct pam *  const outpamP,
         outpamP->maxval = inpam1.maxval;
     }
     outpamP->bytes_per_sample = (pm_maxvaltobits(outpamP->maxval)+7)/8;
-    strcpy(outpamP->tuple_type, inpam1.tuple_type);
+
+    if (outpamP->maxval > 1 && strneq(inpam1.tuple_type, "BLACKANDWHITE", 13))
+        strcpy(outpamP->tuple_type, "");
+    else
+        strcpy(outpamP->tuple_type, inpam1.tuple_type);
 }