Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <000301c24241$827cf550$33bc07d5@StrubeNB> From: "Hans Werner Strube" To: Subject: putenv uses volatile memory Date: Mon, 12 Aug 2002 22:47:43 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 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/