Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/stdlib Clear all entries past the NULL while scrubi...



details:   https://anonhg.NetBSD.org/src/rev/e67803a0f76c
branches:  trunk
changeset: 758593:e67803a0f76c
user:      enami <enami%NetBSD.org@localhost>
date:      Wed Nov 10 02:40:08 2010 +0000

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

diffstat:

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

diffs (36 lines):

diff -r 1aa49d67957c -r e67803a0f76c lib/libc/stdlib/getenv.c
--- a/lib/libc/stdlib/getenv.c  Wed Nov 10 02:33:49 2010 +0000
+++ b/lib/libc/stdlib/getenv.c  Wed Nov 10 02:40:08 2010 +0000
@@ -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;
+       }
 }
 
 /*



Home | Main Index | Thread Index | Old Index