about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2021-08-12 01:39:37 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2021-08-12 01:39:37 +0000
commit311a6622e576349fdcf13a4b015911fab4d6f190 (patch)
tree98e2c2235508ee9cb2acbd133357205161be04d6
parentffa495eb1f02bfc0e5f83a17e917e8709ec41356 (diff)
downloadnetpbm-mirror-311a6622e576349fdcf13a4b015911fab4d6f190.tar.gz
netpbm-mirror-311a6622e576349fdcf13a4b015911fab4d6f190.tar.xz
netpbm-mirror-311a6622e576349fdcf13a4b015911fab4d6f190.zip
Release 10.95.01
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4126 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY4
-rw-r--r--generator/pamstereogram.c28
-rw-r--r--version.mk2
3 files changed, 22 insertions, 12 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index 2ce5844a..d3b3f93b 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -3,6 +3,10 @@ Netpbm.
 
 CHANGE HISTORY 
 --------------
+21.08.12 BJH  Release 10.95.01
+
+              pamstereogram: Fix crash with -xbegin=0.  Thanks Scott Pakin.
+              Introduced in Netpbm 10.94.
 
 21.06.30 BJH  Release 10.95.00
 
diff --git a/generator/pamstereogram.c b/generator/pamstereogram.c
index 6e64b127..4bc1ea92 100644
--- a/generator/pamstereogram.c
+++ b/generator/pamstereogram.c
@@ -1220,15 +1220,19 @@ makeImageRow(outGenerator *       const outGenP,
     unsigned int const height = outGenP->pam.height;
 
     unsigned int col;
-    int lastLinked;
+    bool colHasBeenLinked;
+    unsigned int lastLinkedCol;
+        /* Last column to have been linked; meaningless if 'colHasBeenLinked'
+           is false.
+        */
 
-    for (col = xbegin, lastLinked = -1; col < width; ++col) {
+    for (col = xbegin, colHasBeenLinked = false; col < width; ++col) {
 
         tuple newtuple;
 
         if (sameL[col] == col || sameL[col] < xbegin) {
-            if (lastLinked == col - 1)
-                newtuple = outRow[col - 1];
+            if (colHasBeenLinked && lastLinkedCol == col - 1)
+                newtuple = outRow[lastLinkedCol];
             else {
                 if (col < xbegin + farWidth)
                     newtuple = outGenP->getTuple(outGenP, col, row);
@@ -1237,19 +1241,20 @@ makeImageRow(outGenerator *       const outGenP,
                         outGenP, col, (row + height - yfillshift) % height);
             }
         } else {
-          newtuple = outRow[sameL[col]];
-          lastLinked = col;
-              /* Keep track of the last pixel to be constrained. */
+            newtuple = outRow[sameL[col]];
+            colHasBeenLinked = true;
+            lastLinkedCol = col;
+                /* Keep track of the last pixel to be constrained. */
         }
         pnm_assigntuple(&outGenP->pam, outRow[col], newtuple);
     }
 
-    for (col = xbegin, lastLinked = -1; col > 0; --col) {
+    for (col = xbegin, colHasBeenLinked = false; col > 0; --col) {
         tuple newtuple;
 
         if (sameR[col-1] == col-1) {
-            if (lastLinked == col)
-                newtuple = outRow[col];
+            if (colHasBeenLinked && lastLinkedCol == col)
+                newtuple = outRow[lastLinkedCol];
             else {
                 if (col > xbegin - farWidth)
                     newtuple = outGenP->getTuple(outGenP, col-1, row);
@@ -1259,7 +1264,8 @@ makeImageRow(outGenerator *       const outGenP,
             }
         } else {
             newtuple = outRow[sameR[col-1]];
-            lastLinked = col-1;
+            colHasBeenLinked = true;
+            lastLinkedCol = col - 1;
                 /* Keep track of the last pixel to be constrained. */
         }
         pnm_assigntuple(&outGenP->pam, outRow[col-1], newtuple);
diff --git a/version.mk b/version.mk
index 7e2622ec..b83b493d 100644
--- a/version.mk
+++ b/version.mk
@@ -1,3 +1,3 @@
 NETPBM_MAJOR_RELEASE = 10
 NETPBM_MINOR_RELEASE = 95
-NETPBM_POINT_RELEASE = 0
+NETPBM_POINT_RELEASE = 1