Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/stdlib protect the __allocenv call with the mutex; ...



details:   https://anonhg.NetBSD.org/src/rev/848d2b93c783
branches:  trunk
changeset: 757809:848d2b93c783
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Sep 24 14:34:44 2010 +0000

description:
protect the __allocenv call with the mutex; from Enami

diffstat:

 lib/libc/stdlib/unsetenv.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (31 lines):

diff -r 70e52a596949 -r 848d2b93c783 lib/libc/stdlib/unsetenv.c
--- a/lib/libc/stdlib/unsetenv.c        Fri Sep 24 14:31:15 2010 +0000
+++ b/lib/libc/stdlib/unsetenv.c        Fri Sep 24 14:34:44 2010 +0000
@@ -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 @@
                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]);



Home | Main Index | Thread Index | Old Index