GraphicsMagick: ExpandFilenames(): Address possible memory leak ...

GraphicsMagick Commits <[email protected]> Wed, 15 May 2024 16:58:43 -0500
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.2475.1715810336.7906.graphicsmagick-commit@lists.sourceforge.net>
changeset 9fc6ce00459e in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=9fc6ce00459e
summary: ExpandFilenames(): Address possible memory leak of filelist.

diffstat:

 ChangeLog          |  6 ++++++
 magick/utility.c   |  6 ++++++
 www/ChangeLog.html |  8 ++++++++
 3 files changed, 20 insertions(+), 0 deletions(-)

diffs (47 lines):

diff -r 5488b9864182 -r 9fc6ce00459e ChangeLog
--- a/ChangeLog	Wed May 15 16:09:31 2024 -0500
+++ b/ChangeLog	Wed May 15 16:58:08 2024 -0500
@@ -1,3 +1,9 @@
+2024-05-15  Bob Friesenhahn  <[email protected]>
+
+	* magick/utility.c (ExpandFilenames): Address Coverity 425853:
+	"Resource leaks (RESOURCE_LEAK) Variable "filelist" going out of
+	scope leaks the storage it points to.".
+
 2024-05-15  Fojtik Jaroslav  <[email protected]>
 
 	* coders/tiff.c: Fixed problem with overflowing IFD.
diff -r 5488b9864182 -r 9fc6ce00459e magick/utility.c
--- a/magick/utility.c	Wed May 15 16:09:31 2024 -0500
+++ b/magick/utility.c	Wed May 15 16:58:08 2024 -0500
@@ -1128,6 +1128,12 @@
              for (j=0 ; j < count; j++)
                MagickFreeMemory(vector[j]);
              MagickFreeMemory(vector);
+             if (filelist != (char **) NULL)
+               {
+                 for (j=0; j < number_files; j++)
+                   MagickFreeMemory(filelist[j]);
+                 MagickFreeMemory(filelist);
+               }
              return(MagickFail);
            }
          vector=new_vector;
diff -r 5488b9864182 -r 9fc6ce00459e www/ChangeLog.html
--- a/www/ChangeLog.html	Wed May 15 16:09:31 2024 -0500
+++ b/www/ChangeLog.html	Wed May 15 16:58:08 2024 -0500
@@ -38,6 +38,14 @@
 
 <div class="document" id="graphicsmagick-changelog">
 <h1 class="title">GraphicsMagick ChangeLog</h1>
+<p>2024-05-15  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li><p>magick/utility.c (ExpandFilenames): Address Coverity 425853:
+&quot;Resource leaks (RESOURCE_LEAK) Variable &quot;filelist&quot; going out of
+scope leaks the storage it points to.&quot;.</p></li>
+</ul>
+</blockquote>
 <p>2024-05-15  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;yandex&#46;com">JaFojtik<span>&#64;</span>yandex<span>&#46;</span>com</a>&gt;</p>
 <blockquote>
 <ul class="simple">