[prev in list] [next in list] [prev in thread] [next in thread] 

List:       graphicsmagick-commit
Subject:    [GM-commit] GraphicsMagick: HISTOGRAM: Fix memory leak in error path in writer
From:       GraphicsMagick Commits <graphicsmagick-commit () lists ! sourceforge ! net>
Date:       2017-09-30 21:48:44
Message-ID: mailman.1888.1506808135.12861.graphicsmagick-commit () lists ! sourceforge ! net
[Download RAW message or body]

changeset 9e6afa7ba7b9 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=9e6afa7ba7b9
                
summary: HISTOGRAM: Fix memory leak in error path in writer

diffstat:

 ChangeLog          |   3 +++
 coders/histogram.c |  13 ++++++++-----
 www/Changelog.html |   2 ++
 3 files changed, 13 insertions(+), 5 deletions(-)

diffs (62 lines):

diff -r 57ea336cefaa -r 9e6afa7ba7b9 ChangeLog
--- a/ChangeLog	Sat Sep 30 16:44:18 2017 -0500
+++ b/ChangeLog	Sat Sep 30 16:48:42 2017 -0500
@@ -1,5 +1,8 @@
 2017-09-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
+	* coders/histogram.c (WriteHISTOGRAMImage): Fix SourceForge issue
+	#492 "memory leak in WriteHISTOGRAMImage".
+
 	* coders/gif.c (WriteGIFImage): Fix SourceForge issue #491 "memory
 	leak in WriteGIFImage".
 
diff -r 57ea336cefaa -r 9e6afa7ba7b9 coders/histogram.c
--- a/coders/histogram.c	Sat Sep 30 16:44:18 2017 -0500
+++ b/coders/histogram.c	Sat Sep 30 16:48:42 2017 -0500
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -195,7 +195,7 @@
   unsigned int
     status;
 
-  unsigned long
+  size_t
     length;
 
   /*
@@ -222,12 +222,15 @@
     Allocate histogram count arrays.
   */
   length=Max(ScaleQuantumToChar(MaxRGB)+1,histogram_image->columns);
-  red=MagickAllocateMemory(long *,length*sizeof(long));
-  green=MagickAllocateMemory(long *,length*sizeof(long));
-  blue=MagickAllocateMemory(long *,length*sizeof(long));
+  red=MagickAllocateArray(long *,length,sizeof(long));
+  green=MagickAllocateArray(long *,length,sizeof(long));
+  blue=MagickAllocateArray(long *,length,sizeof(long));
   if ((red == (long *) NULL) || (green == (long *) NULL) ||
       (blue == (long *) NULL))
     {
+      MagickFreeMemory(red);
+      MagickFreeMemory(green);
+      MagickFreeMemory(blue);
       DestroyImage(histogram_image);
       ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image)
     }
diff -r 57ea336cefaa -r 9e6afa7ba7b9 www/Changelog.html
--- a/www/Changelog.html	Sat Sep 30 16:44:18 2017 -0500
+++ b/www/Changelog.html	Sat Sep 30 16:48:42 2017 -0500
@@ -38,6 +38,8 @@
 <p>2017-09-30  Bob Friesenhahn  &lt;<a class="reference external" \
href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#6 \
4;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
  <blockquote>
 <ul class="simple">
+<li>coders/histogram.c (WriteHISTOGRAMImage): Fix SourceForge issue
+#492 &quot;memory leak in WriteHISTOGRAMImage&quot;.</li>
 <li>coders/gif.c (WriteGIFImage): Fix SourceForge issue #491 &quot;memory
 leak in WriteGIFImage&quot;.</li>
 <li>coders/fits.c (WriteFITSImage): Fix SourceForge issue #490

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Graphicsmagick-commit mailing list
Graphicsmagick-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-commit


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic