From f7675b46b77133b516c407fdd9f63abcca50fd45 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Mon, 31 Dec 2018 22:02:27 +1100 Subject: [PATCH] addi style makemap could potentially read one past the end of an array --- Changes | 3 +++ quant.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 0847cf88..82644d70 100644 --- 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 e831abf3..9d6e947d 100644 --- 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++; } -- 2.39.5