changeset 17007:2d65f823588d

clean-temp: Fix memory leak. * lib/clean-temp.c (cleanup_temp_dir): Free also the 'subdirs' and 'files' members of tmpdir.
author John Darrington <john@darrington.wattle.id.au>
date Sun, 29 Jul 2012 00:30:48 +0200
parents f2da6ed0256a
children 631997178451
files ChangeLog lib/clean-temp.c
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-07-28  John Darrington  <john@darrington.wattle.id.au>
+
+	clean-temp: Fix memory leak.
+	* lib/clean-temp.c (cleanup_temp_dir): Free also the 'subdirs' and
+	'files' members of tmpdir.
+
 2012-07-27  Jim Meyering  <meyering@redhat.com>
 
 	maint.mk: new rule: refresh-gnulib-patches
--- a/lib/clean-temp.c
+++ b/lib/clean-temp.c
@@ -556,7 +556,10 @@
           }
         else
           cleanup_list.tempdir_list[i] = NULL;
-        /* Now only we can free the tmpdir->dirname and tmpdir itself.  */
+        /* Now only we can free the tmpdir->dirname, tmpdir->subdirs,
+           tmpdir->files, and tmpdir itself.  */
+        gl_list_free (tmpdir->files);
+        gl_list_free (tmpdir->subdirs);
         free (tmpdir->dirname);
         free (tmpdir);
         return err;