This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

putenv uses volatile memory


Cygwin version: 1.3.12-2.
Function putenv() obviously stores only the address of the argument
string, not its contents. Thus it works reliably only for static, unchanged
argument strings. Consider the command sequence
        char env[256];
        strcpy(env,"EINS=one");
        putenv(env);
        strcpy(env,"ZWEI=two");
/*      putenv(env);*/
With or without the last putenv(), only the environment ZWEI=two
exists now, the first one has been overwritten.
Workaround: #define putenv(x) putenv(strdup(x))




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]