Module Name: src
Committed By: tron
Date: Sat Oct 2 10:05:55 UTC 2010
Modified Files:
src/lib/libc/stdlib: putenv.c
Log Message:
Remember that we didn't malloc() memory for an environment variable
if it has been set via putenv(3).
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/stdlib/putenv.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/stdlib/putenv.c
diff -u src/lib/libc/stdlib/putenv.c:1.13 src/lib/libc/stdlib/putenv.c:1.14
--- src/lib/libc/stdlib/putenv.c:1.13 Fri Oct 1 20:11:32 2010
+++ src/lib/libc/stdlib/putenv.c Sat Oct 2 10:05:55 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: putenv.c,v 1.13 2010/10/01 20:11:32 christos Exp $ */
+/* $NetBSD: putenv.c,v 1.14 2010/10/02 10:05:55 tron Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)putenv.c 8.2 (Berkeley) 3/27/94";
#else
-__RCSID("$NetBSD: putenv.c,v 1.13 2010/10/01 20:11:32 christos Exp $");
+__RCSID("$NetBSD: putenv.c,v 1.14 2010/10/02 10:05:55 tron Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -72,8 +72,10 @@
if (__allocenv(offset) == -1)
goto bad;
- if (p != NULL && environ[offset] == __environ_malloced[offset])
+ if (p != NULL && environ[offset] == __environ_malloced[offset]) {
free(__environ_malloced[offset]);
+ __environ_malloced[offset] = NULL;
+ }
environ[offset] = str;
rwlock_unlock(&__environ_lock);