Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Apr 2007 20:26:32 -0500 (CDT)
From:      "Sean C. Farley" <sean-freebsd@farley.org>
To:        Julian Elischer <julian@elischer.org>
Cc:        freebsd-current@freebsd.org
Subject:   Re: Fix for memory leak in setenv/unsetenv (take 2)
Message-ID:  <20070419201412.K45440@thor.farley.org>
In-Reply-To: <46281223.8060800@elischer.org>
References:  <20070419175902.R44041@thor.farley.org> <46281223.8060800@elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 19 Apr 2007, Julian Elischer wrote:

> Sean C. Farley wrote:
>> I have a new patch that fixes memory leaks caused by repeated calls
>> to setenv() with varying-sized values or unsetenv().  The web page
>> has a better description about it.
>
> I vaguely remember that several people have tried to fix this before,
> but that fixing it actually breaks some ABI..

I have been trying to fix it off and on since 2005[1].  :)  I believe I
have a change that does break the ABI.

unsetenv(3) does not currently follow the standard by returning an int.
I kept the void but recommend switching to an int.

> I may be wrong but maybe others remember better what the issue was.
> I believe that the end result was that it was considered better to leak
> memory than break the posix specified ABI in some way.

This patch still leaks memory in the sense that all calls to getenv()
have valid pointers (non-freed) throughout the run of the program.  It
only cleans up when the library exits.

Sean
   1. http://lists.freebsd.org/pipermail/freebsd-hackers/2005-February/010463.html
-- 
sean-freebsd@farley.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070419201412.K45440>