about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-03-27 03:11:13 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-03-27 03:11:13 +0000
commit6f9d75acb45235a93b1520beec7f96a98bde0412 (patch)
tree903719a5984cd8008cdd079af7a445de271c23e4
parente15e137ba527ba97c82149ad8c6bed59088d8616 (diff)
downloadnetpbm-mirror-6f9d75acb45235a93b1520beec7f96a98bde0412.tar.gz
netpbm-mirror-6f9d75acb45235a93b1520beec7f96a98bde0412.tar.xz
netpbm-mirror-6f9d75acb45235a93b1520beec7f96a98bde0412.zip
Release 10.73.39
git-svn-id: http://svn.code.sf.net/p/netpbm/code/super_stable@4314 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--analyzer/pgmtexture.c3
-rw-r--r--converter/other/pnmtorle.c36
-rw-r--r--converter/ppm/picttoppm.c6
-rw-r--r--converter/ppm/ppmtoapplevol.c6
-rw-r--r--converter/ppm/ppmtoilbm.c1
-rw-r--r--doc/HISTORY38
-rw-r--r--editor/pamsistoaglyph.c7
-rw-r--r--editor/specialty/pgmabel.c11
-rw-r--r--other/pambayer.c38
-rw-r--r--other/pamendian.c2
-rw-r--r--other/pamx/window.c2
-rw-r--r--version.mk2
12 files changed, 131 insertions, 21 deletions
diff --git a/analyzer/pgmtexture.c b/analyzer/pgmtexture.c
index 07317336..ea0db9b0 100644
--- a/analyzer/pgmtexture.c
+++ b/analyzer/pgmtexture.c
@@ -95,6 +95,7 @@ vector(unsigned int const nl,
        unsigned int const nh) {
 
     float * v;
+    unsigned int i;
 
     assert(nh >= nl);
 
@@ -103,6 +104,8 @@ vector(unsigned int const nl,
     if (v == NULL)
         pm_error("Unable to allocate memory for a vector.");
 
+    for(i = 0; i < nh - nl +1; ++i)
+        v[i] = 0;
     return v - nl;
 }
 
diff --git a/converter/other/pnmtorle.c b/converter/other/pnmtorle.c
index 8908c356..7c378246 100644
--- a/converter/other/pnmtorle.c
+++ b/converter/other/pnmtorle.c
@@ -207,12 +207,35 @@ write_rle_data(void) {
 
 
 
+static void
+skip_data(FILE      * const fp,
+          int         const width,
+          int         const height,
+          gray        const maxval,
+          int         const format) {
+
+    xel * xelrow;
+    unsigned int scan;
+
+    MALLOCARRAY(xelrow, width);
+    if (xelrow == NULL)
+        pm_error("Failed to allocate memory for row of %u pixels", width);
+
+    for(scan=0; scan < height; ++scan)
+        pnm_readpnmrow(fp, xelrow, width, maxval, format);
+
+    free(xelrow);
+}
+
+
+
 int
 main(int argc, char **  argv) {
 
     const char * pnmname;
     const char * outname;
     int oflag;
+    int eof;
 
     pnm_init(&argc, argv);
 
@@ -245,18 +268,17 @@ main(int argc, char **  argv) {
 
     hdr.rle_file = rle_open_f( hdr.cmd, outname, "wb" );
 
-    if (header)
+    for (eof = 0; !eof; ) {
         read_pnm_header();
-    else {
-        int eof;
-        for (eof = 0; !eof; ) {
-            read_pnm_header();
+
+        if (header)
+            skip_data(fp, width, height, maxval, format);
+        else {
             rle_addhist(argv, NULL, &hdr);
             write_rle_header();
             write_rle_data();
-            
-            pnm_nextimage(fp, &eof);
         }
+        pnm_nextimage(fp, &eof);
     }
     pm_close(fp);
 
diff --git a/converter/ppm/picttoppm.c b/converter/ppm/picttoppm.c
index 1a833b33..f5fbd7be 100644
--- a/converter/ppm/picttoppm.c
+++ b/converter/ppm/picttoppm.c
@@ -1273,7 +1273,7 @@ doDiffSize(struct Rect       const clipsrc,
     }
     break;
     case 32: {
-        unsigned int const planeSize = srcwid / 4;
+        unsigned int const planeSize = rectwidth(&srcRect);
         unsigned int rowNumber;
         
         for (rowNumber = 0; rowNumber < ysize; ++rowNumber) {
@@ -1443,7 +1443,7 @@ doSameSize(transfer_func           trf,
         }
     } break;
     case 32: {
-        unsigned int const planeSize = srcwid / 4;
+        unsigned int const planeSize = xsize;
         unsigned int rowNumber;
 
         for (rowNumber = 0; rowNumber < ysize; ++rowNumber) {
@@ -1526,7 +1526,7 @@ blitIdempotent(unsigned int          const pixSize,
         }
     } break;
     case 32: {
-        unsigned int const planeSize = srcwid / 4;
+        unsigned int const planeSize = xsize;
         unsigned int rowNumber;
 
         for (rowNumber = 0; rowNumber < ysize; ++rowNumber) {
diff --git a/converter/ppm/ppmtoapplevol.c b/converter/ppm/ppmtoapplevol.c
index e1c7f2dc..eb4b6b2a 100644
--- a/converter/ppm/ppmtoapplevol.c
+++ b/converter/ppm/ppmtoapplevol.c
@@ -68,6 +68,10 @@ main (int argc, const char * argv[]) {
     if (rows != 12)
         pm_error("Input image must be 12 rows tall.  Yours is %u", rows);
 
+    if (cols > 255)
+        pm_error("Input image must not be more than 255 columns wide."
+                 "  Yours is %u", cols);
+
     writeHeader(cols, stdout);
 
     pixelrow = ppm_allocrow(cols);
@@ -75,7 +79,7 @@ main (int argc, const char * argv[]) {
     for (row = 0; row < rows; row++) {
         unsigned int col;
         
-        ppm_readppmrow(stdin, pixelrow, cols, maxval, format);
+        ppm_readppmrow(ifP, pixelrow, cols, maxval, format);
 
         for (col = 0; col < cols; ++col) {
             unsigned int const maxval15Value =
diff --git a/converter/ppm/ppmtoilbm.c b/converter/ppm/ppmtoilbm.c
index 595aa3f4..c5fa4d00 100644
--- a/converter/ppm/ppmtoilbm.c
+++ b/converter/ppm/ppmtoilbm.c
@@ -2274,6 +2274,7 @@ main(int argc, char ** argv) {
         if (colors == 0)
             pm_error("empty colormap??");
         pm_message("%d colors found in colormap", colors);
+        nPlanes = pm_maxvaltobits(colors-1);
     }
 
     if (maskmethod != mskNone) {
diff --git a/doc/HISTORY b/doc/HISTORY
index 005dd131..61a066d6 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -4,6 +4,44 @@ Netpbm.
 CHANGE HISTORY 
 --------------
 
+22.03.27 BJH  Release 10.73.39
+
+              pamx: Fix bug: top-justifies image in all cases where it should
+              bottom-justify.  Always broken.  (pamx was new in Netpbm 10.34
+              (June 2006).
+
+              pnmtorle: Fix bug: -h works only on first image.
+
+              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.
+
+              ppmtoapplevol: Fix bug: reads from Standard Input even when you
+              specify the input file argument.  Always broken.  (ppmtoapplevol
+              was new in Netpbm 10.54 (March 2011).
+
+              ppmtoapplevol: Fix bug: produces garbage with input image wider
+              than 255.  Always broken.  (ppmtoapplevol was new in Netpbm
+              10.54 (March 2011).
+
+              picttoppm: Fix incorrect output for 32 bit per pixel images
+              that have only 3 planes.  Broken in Netpbm 10.34 (June 2006).
+
+              pamendian: fix bogus "sample exceeds maxval" failure.
+              Introduced in Netpbm 10.66 (March 2014).
+
+              ppmtoilbm: Fix wild memory references and hangs with -map .
+              Introduced in Netpbm 9.12 (March 2001).
+
+              pgmtexture: Fix incorrect output.  Always broken.  (Program was
+              added in primordial Netpbm in 1991).
+              
+              pambayer: Fix bogus colors at edges.  Always broken (pambayer
+              was new in Release 10.30 (October 2005)).
+
+              pgmabel: Fix incorrect output.  Always broken.  (Program was
+              new in Netpbm 10.3 (July 2002).
+
 21.12.26 BJH  Release 10.73.38
 
               pamtogif: Fix bug: doesn't ignore the input alpha mask when user
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);
         }
diff --git a/editor/specialty/pgmabel.c b/editor/specialty/pgmabel.c
index 1764c5d7..386f0535 100644
--- a/editor/specialty/pgmabel.c
+++ b/editor/specialty/pgmabel.c
@@ -100,20 +100,19 @@ abel ( float *y, int N, double *adl)
 {
     register int n;
     double *rho, *rhop;       /* results and new index                       */
-    float  *yp;               /* new indizes for the y-array                 */
 
     MALLOCARRAY(rho, N);
     if( !rho )
         pm_error( "out of memory" );
+    for (n=0 ; n<N ; n++)
+        rho[n] = 0;
+
     rhop = rho;
-    yp  = y;
 
     for (n=0 ; n<N ; n++)
     {
-        *(rhop++) = ((*yp++) - Sum(n,rho,N,adl))/(adl[n*N+n]);
-/*    *(rhop++) = ((*yp++) - Sum(n,rho,N))/(dr(n,n+0.5,N));  old version */
-        if ( *rhop < 0.0 ) *rhop = 0.0;         /*  error correction !       */
-/*   if (n > 2) rhop[n-1] = (rho[n-2]+rho[n-1]+rho[n])/3.0;  stabilization*/
+        rhop[n] = MAX(0, (y[n] - Sum(n,rho,N,adl))/(adl[n*N+n]));
+            /* Clip to 0 for error correction !  */
     }
     for (n=0 ; n<N ; n++)
         {
diff --git a/other/pambayer.c b/other/pambayer.c
index 7fc1f809..9cffc8f0 100644
--- a/other/pambayer.c
+++ b/other/pambayer.c
@@ -78,6 +78,8 @@ parseCommandLine(int argc, const char ** argv,
     pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
+    free(option_def);
+
     if (argc-1 < 1)
         cmdlineP->inputFilespec = "-";
     else if (argc-1 > 1)
@@ -101,6 +103,41 @@ parseCommandLine(int argc, const char ** argv,
 
 
 static void
+clearTuples(const struct pam * const pamP,
+	    tuple **           const outtuples) {
+
+    unsigned int row;
+    unsigned int col;
+    unsigned int plane;
+
+    if(pamP->height <= 4 || pamP->width <= 4) {
+        for(row=0; row < pamP->height; ++row)
+          for(col=0; col < pamP->width; ++col)
+            for (plane=0; plane < pamP->depth; ++plane)
+              outtuples[row][col][plane] = 0;
+    }
+    else {
+        for(col = 0; col < pamP->width; ++col)
+            for (plane = 0; plane < pamP->depth; ++plane) {
+                outtuples[0][col][plane] = 0;
+                outtuples[1][col][plane] = 0;
+                outtuples[pamP->height-2][col][plane] = 0;
+                outtuples[pamP->height-1][col][plane] = 0;
+          }
+
+        for(row = 2; row < pamP->height - 2; ++row)
+            for (plane = 0; plane < pamP->depth; ++plane) {
+                outtuples[row][0][plane] = 0;
+                outtuples[row][1][plane] = 0;
+                outtuples[row][pamP->width-2][plane] = 0;
+                outtuples[row][pamP->width-1][plane] = 0;
+            }
+    }
+}
+
+
+
+static void
 calc_4(const struct pam * const pamP,
        tuple **           const intuples,
        tuple **           const outtuples,
@@ -319,6 +356,7 @@ main(int argc, const char **argv) {
     makeOutputPam(&inpam, &outpam);
 
     outtuples = pnm_allocpamarray(&outpam);
+    clearTuples(&outpam, outtuples);
 
     for (plane = 0; plane < 3; ++plane) {
         struct compAction const compAction = compActionTable[plane];
diff --git a/other/pamendian.c b/other/pamendian.c
index d82ebd38..c24d9629 100644
--- a/other/pamendian.c
+++ b/other/pamendian.c
@@ -49,6 +49,8 @@ int main(int argc, char *argv[]) {
     intuplerow = pnm_allocpamrow(&inpam);      
     outtuplerow = pnm_allocpamrow(&outpam);
 
+    inpam.maxval = 65535;
+
     for (row = 0; row < inpam.height; row++) {
         unsigned int col;
         pnm_readpamrow(&inpam, intuplerow);
diff --git a/other/pamx/window.c b/other/pamx/window.c
index e2de1577..f0844cc5 100644
--- a/other/pamx/window.c
+++ b/other/pamx/window.c
@@ -365,7 +365,7 @@ placeImage(viewer * const viewerP,
         pixy = (viewerP->height - height) / 2;
     else {
         if ((pixy < 0) && (pixy + height < viewerP->height))
-            pixy = viewerP->height - viewerP->height;
+            pixy = viewerP->height - height;
         if (pixy > 0)
             pixy = 0;
     }
diff --git a/version.mk b/version.mk
index f2b4ef46..5abbd484 100644
--- a/version.mk
+++ b/version.mk
@@ -1,3 +1,3 @@
 NETPBM_MAJOR_RELEASE = 10
 NETPBM_MINOR_RELEASE = 73
-NETPBM_POINT_RELEASE = 38
+NETPBM_POINT_RELEASE = 39