about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-02-27 04:39:35 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-02-27 04:39:35 +0000
commit3a97e716e4335edaf8c4639439674653160b742f (patch)
tree4d31ca0fc4b9b4ee1f7863493fcd02d8ccba7556
parentf4bfa47633fdf63c4aa83feb5f8af2e26319b366 (diff)
downloadnetpbm-mirror-3a97e716e4335edaf8c4639439674653160b742f.tar.gz
netpbm-mirror-3a97e716e4335edaf8c4639439674653160b742f.tar.xz
netpbm-mirror-3a97e716e4335edaf8c4639439674653160b742f.zip
Fix reference to planes 1 and 2 in 1-plane input
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4286 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY4
-rw-r--r--editor/pamsistoaglyph.c7
2 files changed, 9 insertions, 2 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index 0cd7f1c7..ddf752da 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -9,6 +9,10 @@ not yet  BJH  Release 10.98.00
               pnmtosir: Set some possibly meaningless bits in output to zero
               so output is repeatable.
 
+              pamsistoaglyph: Fix invalid memory reference and incorrect
+              output on depth 1 input.  Always broken.  (pamsistoaglyph was
+              new in Netpbm 10.47 (June 2009).  Thanks Scott Pakin.
+
               pambayer: Fix bogus colors at edges.  Always Broken (pambayer
               was new in Release 10.30 (October 2005)).
 
diff --git a/editor/pamsistoaglyph.c b/editor/pamsistoaglyph.c
index 6b093520..f9e25518 100644
--- a/editor/pamsistoaglyph.c
+++ b/editor/pamsistoaglyph.c
@@ -6,7 +6,7 @@
  *
  * ----------------------------------------------------------------------
  *
- * Copyright (C) 2009 Scott Pakin <scott+pbm@pakin.org>
+ * Copyright (C) 2009-2022 Scott Pakin <scott+pbm@pakin.org>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -127,7 +127,10 @@ readAsGray( const char * const fileName,
         for (col = 0; col < pamP->width; ++col) {
             double YP, CbP, CrP;
 
-            pnm_YCbCrtuple( tuplerow[col], &YP, &CbP, &CrP );
+            if (pamP->depth >= 3)
+                pnm_YCbCrtuple(tuplerow[col], &YP, &CbP, &CrP);
+            else
+                YP = (double) tuplerow[col][0];
             grayArray[row][col] = (gray)
                 (YP * maxGrayVal / (double)pamP->maxval);
         }