getcolorcount() leaked in i_count_colors() on too many colors
authorTony Cook <tony@develop-help.com>
Sun, 21 Feb 2016 02:29:18 +0000 (13:29 +1100)
committerTony Cook <tony@develop-help.com>
Sun, 21 Feb 2016 02:29:18 +0000 (13:29 +1100)
The sample array was leaked when the number of colors in the image
exceeded the supplied limit.

image.c

diff --git a/image.c b/image.c
index f280a28..6e1c58e 100644 (file)
--- a/image.c
+++ b/image.c
@@ -1210,7 +1210,8 @@ i_count_colors(i_img *im,int maxc) {
       for(x = 0; x < samp_cnt; ) {
           colorcnt += octt_add(ct, samp[x], samp[x+1], samp[x+2]);
           x += 3;
-          if (colorcnt > maxc) { 
+          if (colorcnt > maxc) {
+             myfree(samp);
               octt_delete(ct); 
               return -1; 
           }