diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-07-04 02:31:03 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-07-04 02:31:03 +0000 |
commit | 168095c7a55fb9033a20ddc698e182f54c28f312 (patch) | |
tree | 0e5a423750b79e6b705da83ec69705a6b6ecee54 | |
parent | b159c21d101453093e12b321fc16ac5657c998d4 (diff) | |
download | netpbm-mirror-168095c7a55fb9033a20ddc698e182f54c28f312.tar.gz netpbm-mirror-168095c7a55fb9033a20ddc698e182f54c28f312.tar.xz netpbm-mirror-168095c7a55fb9033a20ddc698e182f54c28f312.zip |
Fix array bound violation with = 256 colors and -alpha
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@351 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r-- | converter/other/pnmtopng.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/converter/other/pnmtopng.c b/converter/other/pnmtopng.c index c1bed5ba..a8dfa5ad 100644 --- a/converter/other/pnmtopng.c +++ b/converter/other/pnmtopng.c @@ -1254,6 +1254,10 @@ computeUnsortedAlphaPalette(FILE * const ifP, have color index x. alphasOfColor[x][y] is the yth alpha value that appears with color index x (in order of appearance). + The palette we produce does not go out of its way to include the + background color; unless the background color is also in the image, + Caller will have to add it. + To save time, we give up as soon as we know there are more than 'maxPaletteEntries' in the palette. We return *tooBigP indicating whether that was the case. @@ -1267,7 +1271,7 @@ computeUnsortedAlphaPalette(FILE * const ifP, cht = ppm_colorhisttocolorhash(chv, colors); - for (colorIndex = 0; colorIndex < colors + 1; ++colorIndex) { + for (colorIndex = 0; colorIndex < colors; ++colorIndex) { alphasOfColor[colorIndex] = NULL; alphasOfColorCnt[colorIndex] = 0; } @@ -1462,7 +1466,7 @@ compute_alpha_palette(FILE * const ifP, } } } - freeAlphasOfColor(alphas_of_color, colors + 1); + freeAlphasOfColor(alphas_of_color, colors); } } |