about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-02-14 04:27:50 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-02-14 04:27:50 +0000
commit99a1345ecefc62f1ff2d0ccfe41c90abc657995c (patch)
treed451bbc57081b65a08a10b5c26f75c2927b0e440
parent278e20580cc2a30ee5b055192868617bb0d102de (diff)
downloadnetpbm-mirror-99a1345ecefc62f1ff2d0ccfe41c90abc657995c.tar.gz
netpbm-mirror-99a1345ecefc62f1ff2d0ccfe41c90abc657995c.tar.xz
netpbm-mirror-99a1345ecefc62f1ff2d0ccfe41c90abc657995c.zip
Release 10.86.09
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@3737 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY12
-rw-r--r--editor/pamdice.c18
-rw-r--r--lib/pmfileio.c24
-rw-r--r--version.mk2
4 files changed, 45 insertions, 11 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index 186c5289..2b9f83aa 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -4,7 +4,17 @@ Netpbm.
 CHANGE HISTORY 
 --------------
 
-12.12.25 BJH  Release 10.86.08
+20.02.14 BJH  Release 10.86.09
+
+              pamdice: Fix junk output when -width or -height not specified.
+
+              libnetpbm: pm_getline, xvminitoppm, pamtris : Fix bug: crash
+              when reading empty line.
+
+              libnetpbm: pm_read_unknown_size, rawtopgm, zeisstopnm: crash
+              when out of memory
+
+19.12.25 BJH  Release 10.86.08
 
               pamrubber: Fix bug: -frame doesn't work.  Always broken.
               (Pamrubber was new in Netpbm 10.54 (March 2011).
diff --git a/editor/pamdice.c b/editor/pamdice.c
index 2c53a110..f4b05a8d 100644
--- a/editor/pamdice.c
+++ b/editor/pamdice.c
@@ -150,14 +150,15 @@ computeSliceGeometry(struct cmdlineInfo const cmdline,
             *nHorizSliceP = 1 + divup(inpam.height - cmdline.height, 
                                       cmdline.height - cmdline.voverlap);
         *sliceHeightP = cmdline.height;
+
+        *bottomSliceHeightP = 
+            inpam.height - (*nHorizSliceP-1) * (cmdline.height - cmdline.voverlap);
     } else {
         *nHorizSliceP = 1;
         *sliceHeightP = inpam.height;
+        *bottomSliceHeightP = inpam.height;
     }
 
-    *bottomSliceHeightP = 
-        inpam.height - (*nHorizSliceP-1) * (cmdline.height - cmdline.voverlap);
-
     if (cmdline.sliceVertically) {
         if (cmdline.width >= inpam.width)
             *nVertSliceP = 1;
@@ -165,14 +166,14 @@ computeSliceGeometry(struct cmdlineInfo const cmdline,
             *nVertSliceP = 1 + divup(inpam.width - cmdline.width, 
                                      cmdline.width - cmdline.hoverlap);
         *sliceWidthP = cmdline.width;
+        *rightSliceWidthP = 
+            inpam.width - (*nVertSliceP-1) * (cmdline.width - cmdline.hoverlap);
     } else {
         *nVertSliceP = 1;
         *sliceWidthP = inpam.width;
+        *rightSliceWidthP = inpam.width;
     }
 
-    *rightSliceWidthP = 
-        inpam.width - (*nVertSliceP-1) * (cmdline.width - cmdline.hoverlap);
-
     if (verbose) {
         pm_message("Creating %u images, %u across by %u down; "
                    "each %u w x %u h",
@@ -468,7 +469,10 @@ main(int argc, char ** argv) {
 
     for (horizSlice = 0; horizSlice < nHorizSlice; ++horizSlice) {
         unsigned int const thisSliceFirstRow = 
-            horizSlice * (sliceHeight - cmdline.voverlap);
+            horizSlice > 0 ? horizSlice * (sliceHeight - cmdline.voverlap) : 0;
+            /* Note that 'cmdline.voverlap' is not defined when there is only
+               one horizontal slice
+            */
         unsigned int const thisSliceHeight = 
             horizSlice < nHorizSlice-1 ? sliceHeight : bottomSliceHeight;
 
diff --git a/lib/pmfileio.c b/lib/pmfileio.c
index 33f89110..bea01abe 100644
--- a/lib/pmfileio.c
+++ b/lib/pmfileio.c
@@ -815,6 +815,10 @@ pm_read_unknown_size(FILE * const file,
     nalloc = PM_BUF_SIZE;
     MALLOCARRAY(buf, nalloc);
 
+    if (!buf)
+        pm_error("Failed to allocate %lu bytes for read buffer",
+                 (unsigned long) nalloc);
+
     eof = FALSE;  /* initial value */
 
     while(!eof) {
@@ -825,7 +829,10 @@ pm_read_unknown_size(FILE * const file,
                 nalloc += PM_MAX_BUF_INC;
             else
                 nalloc += nalloc;
-            REALLOCARRAY_NOFAIL(buf, nalloc);
+            REALLOCARRAY(buf, nalloc);
+            if (!buf)
+                pm_error("Failed to allocate %lu bytes for read buffer",
+                         (unsigned long) nalloc);
         }
 
         val = getc(file);
@@ -889,14 +896,27 @@ pm_getline(FILE *   const ifP,
                     /* + 2 = 1 for 'c', one for terminating NUL */
                     bufferSz += 128;
                     REALLOCARRAY(buffer, bufferSz);
+                    if (!buffer) {
+                        pm_error("Failed to allocate %lu bytes for buffer "
+                                 "to assemble a line of input",
+                                 (unsigned long) bufferSz);
+                    }
                 }
                 buffer[nReadSoFar++] = c;
             }
         }
     }
 
-    if (gotLine)
+    if (gotLine) {
+        bufferSz = nReadSoFar + 1;
+        REALLOCARRAY(buffer, bufferSz);
+        if (!buffer) {
+            pm_error("Failed to allocate %lu bytes for buffer "
+                     "to assemble a line of input",
+                     (unsigned long) bufferSz);
+        }
         buffer[nReadSoFar] = '\0';
+    }
 
     *eofP      = eof;
     *bufferP   = buffer;
diff --git a/version.mk b/version.mk
index b5c2c0f3..ca222f1d 100644
--- a/version.mk
+++ b/version.mk
@@ -1,3 +1,3 @@
 NETPBM_MAJOR_RELEASE = 10
 NETPBM_MINOR_RELEASE = 86
-NETPBM_POINT_RELEASE = 8
+NETPBM_POINT_RELEASE = 9