Re: Fix for memory leak in setenv/unsetenv (take 2)

From: Sean C. Farley <sean-freebsd_at_farley.org>
Date: Thu, 19 Apr 2007 20:26:32 -0500 (CDT)
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_at_farley.org
Received on Thu Apr 19 2007 - 23:26:40 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:09 UTC