Module Name:    src
Committed By:   enami
Date:           Wed Nov 10 02:40:08 UTC 2010

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

Log Message:
Clear all entries past the NULL while scrubing environ vector.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libc/stdlib/getenv.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/getenv.c
diff -u src/lib/libc/stdlib/getenv.c:1.31 src/lib/libc/stdlib/getenv.c:1.32
--- src/lib/libc/stdlib/getenv.c:1.31	Wed Nov 10 02:33:49 2010
+++ src/lib/libc/stdlib/getenv.c	Wed Nov 10 02:40:08 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: getenv.c,v 1.31 2010/11/10 02:33:49 enami Exp $	*/
+/*	$NetBSD: getenv.c,v 1.32 2010/11/10 02:40:08 enami Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)getenv.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: getenv.c,v 1.31 2010/11/10 02:33:49 enami Exp $");
+__RCSID("$NetBSD: getenv.c,v 1.32 2010/11/10 02:40:08 enami Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -165,13 +165,11 @@
 	if (environ[++offset] == NULL)
 		return;
 
-	for (; environ[offset]; offset++)
-		if (environ[offset] == __environ_malloced[offset]) {
+	for (; environ[offset]; offset++) {
+		if (environ[offset] == __environ_malloced[offset])
 			free(__environ_malloced[offset]);
-			environ[offset] = __environ_malloced[offset] = NULL;
-		}
-
-	environ[offset] = __environ_malloced[offset] = NULL;
+		environ[offset] = __environ_malloced[offset] = NULL;
+	}
 }
 
 /*

Reply via email to