Module Name:    src
Committed By:   tron
Date:           Sat Sep 25 18:37:24 UTC 2010

Modified Files:
        src/lib/libc/stdlib: unsetenv.c

Log Message:
Unlock the environment lock if __alocenv() fails.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/stdlib/unsetenv.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/unsetenv.c
diff -u src/lib/libc/stdlib/unsetenv.c:1.6 src/lib/libc/stdlib/unsetenv.c:1.7
--- src/lib/libc/stdlib/unsetenv.c:1.6	Sat Sep 25 18:11:40 2010
+++ src/lib/libc/stdlib/unsetenv.c	Sat Sep 25 18:37:24 2010
@@ -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]);

Reply via email to