about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2015-04-09 01:48:43 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2015-04-09 01:48:43 +0000
commitfb6b0caf78f6c73f69eedbee7a597fcd11be889c (patch)
treef7cb38793575748e1da1e1f17c6624340f7dc294
parent946e0515bbae993f3ee091c848fdae2bda51e97a (diff)
downloadnetpbm-mirror-fb6b0caf78f6c73f69eedbee7a597fcd11be889c.tar.gz
netpbm-mirror-fb6b0caf78f6c73f69eedbee7a597fcd11be889c.tar.xz
netpbm-mirror-fb6b0caf78f6c73f69eedbee7a597fcd11be889c.zip
Set undefined palette values
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2456 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--converter/ppm/ppmtopcx.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/converter/ppm/ppmtopcx.c b/converter/ppm/ppmtopcx.c
index 4c25ca29..fa68edc5 100644
--- a/converter/ppm/ppmtopcx.c
+++ b/converter/ppm/ppmtopcx.c
@@ -12,6 +12,10 @@
 **
 ** 11/Dec/94: first version
 ** 12/Dec/94: added handling of "packed" format (16 colors or less)
+** 
+** ZSoft PCX File Format Technical Reference Manual
+** http://bespin.org/~qz/pc-gpe/pcx.txt
+** http://web.archive.org/web/20100206055706/http://www.qzx.com/pc-gpe/pcx.txt
 */
 #include <assert.h>
 
@@ -158,6 +162,8 @@ parseCommandLine(int argc, char ** argv,
         pm_error("Program takes at most one argument "
                  "(input file specification).  You specified %d",
                  argc-1);
+
+    free(option_def);
 }
 
 
@@ -632,6 +638,16 @@ generateStandardPalette(struct pcxCmapEntry ** const pcxcmapP,
         putPcxColorInHash(cht, pcxColor, colorIndex, maxval);
     }
 
+    /* Set remaining slots in palette to black.  The values are not
+       meaningful, but this suppresses a Valgrind warning about our writing
+       undefined values to the file and makes our output constant with input.
+    */
+    for ( ; colorIndex < MAXCOLORS; ++colorIndex) {
+        pcxcmap[colorIndex].r = 0;
+        pcxcmap[colorIndex].g = 0;
+        pcxcmap[colorIndex].b = 0;
+    }
+
     *chtP = cht;
     *colorsP = stdPaletteSize;
 }