about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2013-05-20 02:47:16 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2013-05-20 02:47:16 +0000
commitae91f9110b73e6d4c737122e2ba6c5b4313dcc27 (patch)
tree68fb4994c8cb4870383352d20910963045696ecd
parentddee347b0bc1fdb87b9bbbd4d5641b5880e88ea3 (diff)
downloadnetpbm-mirror-ae91f9110b73e6d4c737122e2ba6c5b4313dcc27.tar.gz
netpbm-mirror-ae91f9110b73e6d4c737122e2ba6c5b4313dcc27.tar.xz
netpbm-mirror-ae91f9110b73e6d4c737122e2ba6c5b4313dcc27.zip
Fix -norandom: reference to unset variable
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1908 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY4
-rw-r--r--editor/pnmremap.c20
2 files changed, 24 insertions, 0 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index 704e0593..80395f45 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -21,6 +21,10 @@ not yet  BJH  Release 10.63.00
               since at least 10.26 (May 2001), but after 10.18 (September
               2003).  Thanks Ludolf Holzheid (lholzheid@bihl-wiedemann.de).
 
+              pnmremap (ergo pnmquant): fix bug: incorrect output with
+              -norandom and floyd-steinberg dithering.  Always broken.
+              (-norandom was introduced in 10.30 (June 2007)).
+
               pamtilt: fix bug: incorrect output or invalid memory access
               crash.  Always broken (program was new in Neptbm 10.30
               (October 2005)).
diff --git a/editor/pnmremap.c b/editor/pnmremap.c
index dcd4e2a5..ec381f32 100644
--- a/editor/pnmremap.c
+++ b/editor/pnmremap.c
@@ -378,6 +378,24 @@ randomizeError(long **      const err,
 
 
 static void
+zeroError(long **      const err,
+          unsigned int const width,
+          unsigned int const depth) {
+/*----------------------------------------------------------------------------
+   Set all errors to zero in the error array err[][].
+-----------------------------------------------------------------------------*/
+    unsigned int col;
+
+    for (col = 0; col < width; ++col) {
+        unsigned int plane;
+        for (plane = 0; plane < depth; ++plane) 
+            err[plane][col] = 0;
+    }
+}
+
+
+
+static void
 fserrSetForward(struct fserr * const fserrP) {
 
     fserrP->fsForward = TRUE;
@@ -434,6 +452,8 @@ initFserr(struct pam *   const pamP,
 
     if (initRandom)
         randomizeError(fserrP->thiserr, fserrSize, pamP->depth);
+    else
+        zeroError(fserrP->thiserr, fserrSize, pamP->depth);
 
     fserrSetForward(fserrP);
 }