summaryrefslogtreecommitdiffstats
path: root/generic/tclEnv.c
diff options
context:
space:
mode:
authordavygrvy <davygrvy@pobox.com>2002-08-28 22:48:10 (GMT)
committerdavygrvy <davygrvy@pobox.com>2002-08-28 22:48:10 (GMT)
commit278f7c88ca3a17fed8af94c6ec45b4f5dda49861 (patch)
tree9276aaf344a0938ea3d864552a3843ba199c4540 /generic/tclEnv.c
parent3932d4560e1130460563ce7f09cbdc6e8e5fe204 (diff)
downloadtcl-278f7c88ca3a17fed8af94c6ec45b4f5dda49861.zip
tcl-278f7c88ca3a17fed8af94c6ec45b4f5dda49861.tar.gz
tcl-278f7c88ca3a17fed8af94c6ec45b4f5dda49861.tar.bz2
* generic/tclEnv.c:
* unix/configure.in: * win/tclWinPort.h: putenv() on some systems copies the buffer rather than taking reference to it. This causes memory leaks and is know to effect mswindows (msvcrt) and NetBSD 1.5.2 . This patch tests for this behavior and turns on -DHAVE_PUTENV_THAT_COPIES=1 when approriate. Thanks to David Welton for assistance. [Bug 414910] * unix/configure: regen'd
Diffstat (limited to 'generic/tclEnv.c')
-rw-r--r--generic/tclEnv.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/generic/tclEnv.c b/generic/tclEnv.c
index 6e3b106..75f5eab 100644
--- a/generic/tclEnv.c
+++ b/generic/tclEnv.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclEnv.c,v 1.16 2002/08/05 03:24:40 dgp Exp $
+ * RCS: @(#) $Id: tclEnv.c,v 1.17 2002/08/28 22:48:10 davygrvy Exp $
*/
#include "tclInt.h"
@@ -275,6 +275,11 @@ TclSetEnv(name, value)
if ((index != -1) && (environ[index] == p)) {
ReplaceString(oldValue, p);
+#ifdef HAVE_PUTENV_THAT_COPIES
+ } else {
+ /* This putenv() copies instead of taking ownership */
+ ckfree(p);
+#endif
}
Tcl_MutexUnlock(&envMutex);