Modifying the strings returned by the standard functions getenv(), strerror() and setlocale() is undefined. So, implementations may use static storage for these strings.
The getenv() function, C11, §7.22.4.7, 4, says:
The getenv function returns a pointer to a string associated with the
matched...