From b3c523f23f5c7e3777d0cbb4094737da84b0fa90 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Tue, 8 Sep 2020 00:46:04 +0000 Subject: 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 --- doc/HISTORY | 4 ++-- other/pamarith.c | 7 ++++++- 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); } -- cgit 1.4.1