...
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
mainandwmainis a "frozen" copy of the current environment. If you subsequently change the environment via a call to_putenvor_wputenv, the current environment (as returned bygetenv/_wgetenvand the_environ/_wenvironvariable) will change, but the block pointed to byenvpwill not change.
...