addi style makemap could potentially read one past the end of an array
[imager.git] / quant.c
diff --git a/quant.c b/quant.c
index e831abf..9d6e947 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++;
   }