Re: setenv memory leak fix (take 3)

From: Andrey Chernov <ache_at_freebsd.org>
Date: Tue, 1 May 2007 11:39:05 +0400
On Mon, Apr 30, 2007 at 09:04:46PM -0500, Sean C. Farley wrote:

>    2. http://www.farley.org/freebsd/tmp/setenv-8/POSIX/sysenv.c

putenv():
/* Create environment entry. */
	envVars[envNdx].name = string;
	envVars[envNdx].nameLen = nameLen;
	envVars[envNdx].value = equals + 1;
	envVars[envNdx].valueSize = valueLen;

It will not work that way. "string" is just passed buffer which can be 
altered any time until the next set|putenv call. It means that you can't 
assume "nameLen", "equals" position and "valueLen" will stay the same as 
at the moment of the call.

-- 
http://ache.pp.ru/
Received on Tue May 01 2007 - 05:39:17 UTC

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