]> git.imager.perl.org - imager.git/commitdiff
addi style makemap could potentially read one past the end of an array
authorTony Cook <tony@develop-help.com>
Mon, 31 Dec 2018 11:02:27 +0000 (22:02 +1100)
committerTony Cook <tony@develop-help.com>
Mon, 31 Dec 2018 11:02:27 +0000 (22:02 +1100)
Changes
quant.c

diff --git a/Changes b/Changes
index 0847cf8814d8f112260b961ccd8b48e7a28dc398..82644d70820cbf946c15e97285d8493f9fd92685 100644 (file)
--- a/Changes
+++ b/Changes
@@ -18,6 +18,9 @@ Coverity finally finished a build, fix a few problems:
  - initialize a pointer to prevent Coverity complaining in polygon
    drawing (it should always end up being set.)
 
+ - addi style makemap could potentially read one past the end of an
+   array.
+
 Imager 1.008 - 31 Dec 2018
 ============
 
diff --git a/quant.c b/quant.c
index e831abf3e88e8bf886837dd162b82e3b2d49473e..9d6e947d966028b8685d5c33eade3eeb9c80eeb0 100644 (file)
--- a/quant.c
+++ b/quant.c
@@ -1514,7 +1514,7 @@ static void reorder(pbox prescan[512]) {
   c.cand++;
   c.pdc=c.pixcnt/(c.cand*c.cand); 
   /*  c.pdc=c.pixcnt/c.cand; */
-  while(c.pdc < prescan[nidx+1].pdc && nidx < 511) {
+  while(nidx < 511 && c.pdc < prescan[nidx+1].pdc) {
     prescan[nidx]=prescan[nidx+1];
     nidx++;
   }