Subject: bug#12542: closed (Re: bug#12542: [PATCH] du: avoid abort on systems for which ->me_type is not malloc'd)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 30 Sep 2012 12:44:01 +0000

Your bug report

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

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
12542: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12542
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#12542: [PATCH] du: avoid abort on systems for which ->me_type is not malloc'd
From: Jim Meyering <[email-masked]>
To: [email-masked]
Date: Sun, 30 Sep 2012 14:43:18 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Jim Meyering wrote:
> 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've just pushed the patch.
A better one should come soon, in which I add
a function in mountlist.c (declared in the .h file)
by which to encapsulate this mount-entry freeing process.

Subject: [PATCH] du: avoid abort on systems for which ->me_type is not malloc'd
From: Jim Meyering <[email-masked]>
To: [email-masked]
Date: Sun, 30 Sep 2012 14:32:35 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

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 <[email-masked]>
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