This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
putenv uses volatile memory
- From: "Hans Werner Strube" <strube at physik3 dot gwdg dot de>
- To: <cygwin at cygwin dot com>
- Date: Mon, 12 Aug 2002 22:47:43 +0200
- Subject: 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/