Module Name:    src
Committed By:   christos
Date:           Thu Nov  4 21:49:46 UTC 2010

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

Log Message:
scrub the whole array, not just the first n malloced entries.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 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.29 src/lib/libc/stdlib/getenv.c:1.30
--- src/lib/libc/stdlib/getenv.c:1.29	Wed Nov  3 11:01:07 2010
+++ src/lib/libc/stdlib/getenv.c	Thu Nov  4 17:49:45 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: getenv.c,v 1.29 2010/11/03 15:01:07 christos Exp $	*/
+/*	$NetBSD: getenv.c,v 1.30 2010/11/04 21:49:45 christos 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.29 2010/11/03 15:01:07 christos Exp $");
+__RCSID("$NetBSD: getenv.c,v 1.30 2010/11/04 21:49:45 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -165,12 +165,11 @@
 	if (environ[++offset] == NULL)
 		return;
 
-	while (environ[offset] &&
-	    environ[offset] == __environ_malloced[offset]) {
-		free(__environ_malloced[offset]);
-		environ[offset] = __environ_malloced[offset] = NULL;
-		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;
 }

Reply via email to