diff options
| author | tron <tron@NetBSD.org> | 2010-10-02 10:05:55 +0000 |
|---|---|---|
| committer | tron <tron@NetBSD.org> | 2010-10-02 10:05:55 +0000 |
| commit | 12c10b36d2bc9b8dcc24af6d01008ed2e86f41e7 (patch) | |
| tree | 2894cf36c6e63b3ec8314395805ebacf84287213 /lib/libc/stdlib/putenv.c | |
| parent | 98bb28c039367fa2e64727ecbf9cd2fae804f0a2 (diff) | |
Remember that we didn't malloc() memory for an environment variable
if it has been set via putenv(3).
Diffstat (limited to 'lib/libc/stdlib/putenv.c')
| -rw-r--r-- | lib/libc/stdlib/putenv.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc/stdlib/putenv.c b/lib/libc/stdlib/putenv.c index 00a69bf8d6e..44e42016223 100644 --- a/lib/libc/stdlib/putenv.c +++ b/lib/libc/stdlib/putenv.c @@ -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 @@ putenv(char *str) 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); |
