ratpoison-devel
[Top][All Lists]
Advanced

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

Re: [RP] Fix for ratpoison OpenBSD-Port


From: Matthias Kilian
Subject: Re: [RP] Fix for ratpoison OpenBSD-Port
Date: Fri Oct 8 02:07:26 2004
User-agent: Mutt/1.3.28i

On Thu, Oct 07, 2004 at 07:49:31PM -0700, Shawn Betts wrote:
> > It works, but there's a memory leak. May I suggest an additional
> > patch? [untested, but it's trivial]
> 
> Are you sure? The putenv man page say:
> 
>    The string pointed to by string becomes part of the environ- ment, so
>    altering the string changes the environment.

Oh Shit. That's different semantic than the OpenBSD putenv(3).

So one probably should not use putenv(3) at all. It seems to be broken
by design, at least in glibc and uClibc, since you would have to do
housekeeping on every single call to it, i.e. "Did *I* allocate it?
Did some other function allocate it? Or is it static? If allocated,
is it still in use somewhere else?"

> Which would suggest that freeing that string frees the environment.

Yes, but not freeing it means that you have a leak.

So the choice seems to be: break it, have a leak, or don't use putenv(3).

Ciao,
        Kili



reply via email to

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