Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@sources.redhat.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@sources.redhat.com>
List-Help: <mailto:cygwin-help@sources.redhat.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@sources.redhat.com
Delivered-To: mailing list cygwin@sources.redhat.com
Date: Fri, 22 Sep 2000 15:50:51 -0400
From: Jason Tishler <Jason.Tishler@dothill.com>
To: Earnie Boyd <earnie_boyd@yahoo.com>
Cc: "Dr. Volker Zell" <Dr.Volker.Zell@oracle.com>,
        Cygwin <cygwin@sources.redhat.com>, pgsql-ports@postgresql.org
Subject: Re: Problem Building Cygwin PostgreSQL
Message-ID: <20000922155051.A2515@DP>
References: <20000922180125.13815.qmail@web110.yahoomail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.2.4i
In-Reply-To: <20000922180125.13815.qmail@web110.yahoomail.com>; from earnie_boyd@yahoo.com on Fri, Sep 22, 2000 at 11:01:25AM -0700
Organization: Dot Hill Systems Corp.

Earnie,

On Fri, Sep 22, 2000 at 11:01:25AM -0700, Earnie Boyd wrote:
> Hmm...  This appears that it would potentially cause a memory leak.  What
> happens if instead of this patch you initialize the pointer to NULL?

I guess that I should have giving more context:

    void
    usage(void)
    {
        ...
        user = getenv("USER");
        if (!user)
        {
    #ifndef WIN32
            pw = getpwuid(geteuid());
            if (pw)
                user = pw->pw_name;
            ...
    #else
            user = "?";
    #endif
        }
        ...
    #if !defined(WIN32) && !defined(__CYGWIN__)
        if (pw)
            free(pw);
    #endif
    }

The relevant Cygwin source (i.e., src/winsup/cygwin/passwd.cc) and the
getpwuid() man page (from Solaris):

    The  functions  getpwnam(),  getpwuid(),   getpwent(),   and
    fgetpwent() use *static* storage that is re-used in each call,
    making these routines unsafe for use in multithreaded appli-
    cations.

seemed to indicate that free-ing the return value from getpwuid() was a
bad idea.  Can someone confirm or refute this supposition?

Thanks,
Jason

-- 
Jason Tishler
Director, Software Engineering       Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corporation         Fax:   +1 (732) 264-8798
82 Bethany Road, Suite 7             Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

