...
An environment pointer may also become invalidated by subsequent calls to getenv().
(see See ENV34-C. Do not store pointers returned by certain functions for more information.).
Noncompliant Code Example (POSIX)
...
According to the Visual C++ reference [MSDN],
The environment block passed to
main
andwmain
is a "frozen" copy of the current environment. If you subsequently change the environment via a call to_putenv
or_wputenv
, the current environment (as returned bygetenv
/_wgetenv
and the_environ
/_wenviron
variable) will change, but the block pointed to byenvp
will not change.
...