]> git.imager.perl.org - imager.git/commitdiff
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 f280a28c66030746aee7dc9c6890716397408e5c..6e1c58e02b81d33f314ec6fbc0777d13d17db3f2 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; 
           }