bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#12542: [PATCH] du: avoid abort on systems for which ->me_type is not


From: Jim Meyering
Subject: bug#12542: [PATCH] du: avoid abort on systems for which ->me_type is not malloc'd
Date: Sun, 30 Sep 2012 14:32:35 +0200

I noticed that "make check" was failing a fundamental test of du
on OpenBSD.  It would have been trivial to diagnose with valgrind,
but that tool wasn't easily available on the affected system...

[I'm reporting this to the bug- mailing list, since I suppose we
 should report all bugs there. ]


>From caaf7cce39828ef3e90766fe2d6cc64559c13a60 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 30 Sep 2012 14:28:47 +0200
Subject: [PATCH] du: avoid abort on systems for which ->me_type is not
 malloc'd

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.
---
 src/du.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/du.c b/src/du.c
index ee90da9..63daaa9 100644
--- 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);
     }
 }
--
1.7.12.1.382.gb0576a6





reply via email to

[Prev in Thread] Current Thread [Next in Thread]