From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24280 invoked by alias); 11 Apr 2006 15:12:05 -0000 Received: (qmail 24272 invoked by uid 22791); 11 Apr 2006 15:12:04 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Tue, 11 Apr 2006 15:12:03 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1FTKXA-0007Mt-Ox; Tue, 11 Apr 2006 11:12:00 -0400 Date: Wed, 12 Apr 2006 01:01:00 -0000 From: Daniel Jacobowitz To: Chet Ramey Cc: bug-readline@gnu.org, gdb@sourceware.org, chet@case.edu Subject: Re: MinGW status for readline Message-ID: <20060411151200.GA28268@nevyn.them.org> Mail-Followup-To: Chet Ramey , bug-readline@gnu.org, gdb@sourceware.org, chet@case.edu References: <20060407200149.GA28248@nevyn.them.org> <443BB2CA.20200@case.edu> <20060411135550.GA22588@nevyn.them.org> <443BB9EB.2040701@case.edu> <20060411144053.GA27577@nevyn.them.org> <443BC59F.7040805@case.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <443BC59F.7040805@case.edu> User-Agent: Mutt/1.5.8i X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00139.txt.bz2 On Tue, Apr 11, 2006 at 11:05:03AM -0400, Chet Ramey wrote: > Daniel Jacobowitz wrote: > > On Tue, Apr 11, 2006 at 10:15:07AM -0400, Chet Ramey wrote: > >> No, you never free username. isolate_tilde_prefix allocates memory > >> whether you have the getpwent family available or not. > > > > It should be? user_entry = 0, so the other branch of the if is taken. > > ? > > `username' is assigned before user_entry is. It really should be freed > outside the if-then block, now that I'm looking at it. Well, yeah. But: #if defined (HAVE_GETPWNAM) user_entry = getpwnam (username); #else user_entry = 0; #endif if (user_entry == 0) { /* If the calling program has a special syntax for expanding tildes, and we couldn't find a standard expansion, then let them try. */ if (tilde_expansion_failure_hook) { expansion = (*tilde_expansion_failure_hook) (username); if (expansion) { dirname = glue_prefix_and_suffix (expansion, filename, user_len); free (expansion); } } free (username); /* If we don't have a failure hook, or if the failure hook did not expand the tilde, return a copy of what we were passed. */ if (dirname == 0) dirname = savestring (filename); } #if defined (HAVE_GETPWENT) else { free (username); dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len); } endpwent (); #endif Suppose !HAVE_GETPWENT. Then probably also !HAVE_GETPWNAM. So user_entry = 0, so the first half of the if is taken, and username gets freed. I suppose this would make more sense though: #if defined (HAVE_GETPWNAM) else { free (username); dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len); } #endif #if defined (HAVE_GETPWENT) endpwent (); #endif > > >> (I call endpwent() because its sole usual purpose is to close any open > >> file descriptors on the password database, whatever it is. getpwent > >> and getpwnam usually keep the database open.) > > > > Oh, huh. So much for useful man pages. > > The BSD man pages, at least, say > > The endpwent() function closes any open files. > > Chet > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ( ``Discere est Dolere'' -- chet ) > Live Strong. No day but today. > Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/ > -- Daniel Jacobowitz CodeSourcery