Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/stdlib Unlock the environment lock if __alocenv() f...



details:   https://anonhg.NetBSD.org/src/rev/6cf4d484860d
branches:  trunk
changeset: 757833:6cf4d484860d
user:      tron <tron%NetBSD.org@localhost>
date:      Sat Sep 25 18:37:24 2010 +0000

description:
Unlock the environment lock if __alocenv() fails.

diffstat:

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

diffs (30 lines):

diff -r d3aa5942fa2c -r 6cf4d484860d lib/libc/stdlib/unsetenv.c
--- a/lib/libc/stdlib/unsetenv.c        Sat Sep 25 18:11:40 2010 +0000
+++ b/lib/libc/stdlib/unsetenv.c        Sat Sep 25 18:37:24 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: unsetenv.c,v 1.6 2010/09/25 18:11:40 tron Exp $        */
+/*     $NetBSD: unsetenv.c,v 1.7 2010/09/25 18:37:24 tron 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.6 2010/09/25 18:11:40 tron Exp $");
+__RCSID("$NetBSD: unsetenv.c,v 1.7 2010/09/25 18:37:24 tron Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -67,8 +67,10 @@
        if (rwlock_wrlock(&__environ_lock) != 0)
                return -1;
 
-       if (__allocenv(-1) == -1)
+       if (__allocenv(-1) == -1) {
+               rwlock_unlock(&__environ_lock);
                return -1;
+       }
 
        while (__findenv(name, &offset) != NULL ) { /* if set multiple times */
                free(__environ_malloced[offset]);



Home | Main Index | Thread Index | Old Index