Setenv/putenv changes break existing code.
H.J. Lu
hjl@lucon.org
Mon Aug 2 18:01:00 GMT 1999
Hi,
The recent setenv/putenv change break existing code like:
p = malloc (100);
.....
putenv (p);
free (p);
sice p is used directly in putenv. However, from the Unix standard:
The putenv() function uses the string argument to set environment
variable values. The string argument should point to a string of the
form "name=value". The putenv() function makes the value of the
environment variable name equal to value by altering an existing
variable or creating a new one. In either case, the string pointed to
by string becomes part of the environment, so altering the string will
change the environment. The space used by string is no longer used
once a new string-defining name is passed to putenv().
It seems to me that it is ok to free 'p' since it is no longer used
when returning from putenv ().
This change breaks gdm. I don't know if anything else is broken.
--
H.J. Lu (hjl@gnu.org)
More information about the Libc-hacker
mailing list