Subject: Re: please review: unsetenv memory leak fix
To: None <email@example.com>
From: Ben Harris <firstname.lastname@example.org>
Date: 06/27/2003 18:42:27
In article <HH5Hwv.L6y@tac.nyc.ny.us> you write:
>In article <20030628012855.AC2C.OKI@netbsd.org>,
>Masaru OKI <email@example.com> wrote:
>>unsetenv(3) doesn't call free(3) with environment variable string.
>>following diff is fixed the problem.
>>If it is looks good, I'll commit it later.
>It could break existing code that accesses environ directly...
This could be improved by remembering the address of the block that was
allocated by setenv, and only trying to free anything if the address hasn't
changed by the time unsetenv is called.
Incidentally, POSIX says:
# If the application modifies environ or the pointers to which it points, the
# behavior of unsetenv() is undefined.
Ben Harris <firstname.lastname@example.org>
Portmaster, NetBSD/acorn26 <URL:http://www.netbsd.org/Ports/acorn26/>