]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
du: avoid abort on systems for which ->me_type is not malloc'd
authorJim Meyering <meyering@redhat.com>
Sun, 30 Sep 2012 12:28:47 +0000 (14:28 +0200)
committerJim Meyering <meyering@redhat.com>
Sun, 30 Sep 2012 12:34:20 +0000 (14:34 +0200)
On some systems (notably, BSD-based, like at least OpenBSD 4.9),
the me_type member does not come from the heap.
* src/du.c (fill_mount_table): Free the ->me_type member only
when it was malloc'd, i.e., when ->me_type_malloced is nonzero.
Bug introduced via commit v8.19-2-gcf7e1b5.
Reported as http://bugs.gnu.org/12542.

src/du.c

index ee90da9baeb9adde4fff09b06eba01c0317203e1..63daaa9284d3b42ab953d993f4c052deaf230724 100644 (file)
--- a/src/du.c
+++ b/src/du.c
@@ -660,7 +660,8 @@ fill_mount_table (void)
 
       free (mnt_free->me_devname);
       free (mnt_free->me_mountdir);
-      free (mnt_free->me_type);
+      if (mnt_free->me_type_malloced)
+        free (mnt_free->me_type);
       free (mnt_free);
     }
 }