summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2010-09-24 14:34:44 +0000
committerchristos <christos@NetBSD.org>2010-09-24 14:34:44 +0000
commitda3a4052e4b29fc763afec5472737503f9d3cb7c (patch)
treef1df3cc415e3659676e11d0fe2f97914e4985271 /lib/libc/stdlib
parentf6033a77ae7a5282e3faad9b3ac5c1cbf249d142 (diff)
protect the __allocenv call with the mutex; from Enami
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/unsetenv.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libc/stdlib/unsetenv.c b/lib/libc/stdlib/unsetenv.c
index b1657840029..8fa4f40b267 100644
--- a/lib/libc/stdlib/unsetenv.c
+++ b/lib/libc/stdlib/unsetenv.c
@@ -1,4 +1,4 @@
-/* $NetBSD: unsetenv.c,v 1.4 2010/09/23 17:30:49 christos Exp $ */
+/* $NetBSD: unsetenv.c,v 1.5 2010/09/24 14:34:44 christos Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "from: @(#)setenv.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: unsetenv.c,v 1.4 2010/09/23 17:30:49 christos Exp $");
+__RCSID("$NetBSD: unsetenv.c,v 1.5 2010/09/24 14:34:44 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -66,10 +66,11 @@ unsetenv(name)
return -1;
}
+ rwlock_wrlock(&__environ_lock);
+
if (__allocenv(-1) == -1)
return -1;
- rwlock_wrlock(&__environ_lock);
while (__findenv(name, &offset)) { /* if set multiple times */
if (bit_test(__environ_malloced, offset))
free(environ[offset]);