diff --git a/include/boost/nowide/cstdlib.hpp b/include/boost/nowide/cstdlib.hpp index a48028a1..cfdac7cf 100644 --- a/include/boost/nowide/cstdlib.hpp +++ b/include/boost/nowide/cstdlib.hpp @@ -21,7 +21,12 @@ namespace nowide { /// /// \brief UTF-8 aware getenv. Returns 0 if the variable is not set. /// - /// This function is not thread safe or reenterable as defined by the standard library + /// The string pointed to shall not be modified by the program. + /// This function is thread-safe as long as no other thread modifies the host environment. + /// However subsequent calls to this function might overwrite the string pointed to. + /// + /// Warning: The returned pointer might only be valid for as long as the calling thread is alive. + /// So avoid passing it across thread boundaries. /// BOOST_NOWIDE_DECL char* getenv(const char* key); diff --git a/src/cstdlib.cpp b/src/cstdlib.cpp index ab0d4455..76f0319f 100644 --- a/src/cstdlib.cpp +++ b/src/cstdlib.cpp @@ -52,7 +52,7 @@ namespace boost { namespace nowide { char* getenv(const char* key) { - static stackstring value; + thread_local stackstring value; const wshort_stackstring name(key);