Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/stdlib scrub the whole array, not just the first n ...



details:   https://anonhg.NetBSD.org/src/rev/eb323607df9a
branches:  trunk
changeset: 758440:eb323607df9a
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Nov 04 21:49:45 2010 +0000

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

diffstat:

 lib/libc/stdlib/getenv.c |  15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diffs (36 lines):

diff -r c550b1e6f3be -r eb323607df9a lib/libc/stdlib/getenv.c
--- a/lib/libc/stdlib/getenv.c  Thu Nov 04 21:15:54 2010 +0000
+++ b/lib/libc/stdlib/getenv.c  Thu Nov 04 21:49:45 2010 +0000
@@ -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;
 }



Home | Main Index | Thread Index | Old Index