----- Original Message ----- From: "Christopher Faylor" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, April 21, 2006 4:12 PM
Subject: Re: [Patch] Make getenv() functional before the environment is initialized



But doesn't the program then have a pointer to memory that has been freed?
That pointer can also be accessed after forks.

Isn't that always a possibility?  You can't rely on the persistence of
the stuff returned from getenv().

That's not my reading of http://www.opengroup.org/onlinepubs/000095399/functions/getenv.html

"The string pointed to may be overwritten by a subsequent call to getenv(),
but shall not be overwritten by a call to any other function in this volume of IEEE Std 1003.1-2001."

Athough Posix allows the string to be overwritten, indicating that persistence is implied,
it does not allow the pointer to become invalid.

See also
http://developer.apple.com/documentation/Darwin/Reference/Manpages/man3/getenv.3.html
which says that the environment semantics make it inherently leaky.
That's why I didn't hesitate calling cmalloc

Pierre

Reply via email to