Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/config Make sure to also zero out structures put on...



details:   https://anonhg.NetBSD.org/src/rev/ba113a01b9dd
branches:  trunk
changeset: 555701:ba113a01b9dd
user:      rafal <rafal%NetBSD.org@localhost>
date:      Tue Nov 25 19:34:05 2003 +0000

description:
Make sure to also zero out structures put on local free lists so allocations
satisfied from those lists get zeroed memory back too.

diffstat:

 usr.sbin/config/hash.c |  4 +++-
 usr.sbin/config/util.c |  4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diffs (43 lines):

diff -r 422aa7f04437 -r ba113a01b9dd usr.sbin/config/hash.c
--- a/usr.sbin/config/hash.c    Tue Nov 25 19:05:46 2003 +0000
+++ b/usr.sbin/config/hash.c    Tue Nov 25 19:34:05 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hash.c,v 1.12 2003/11/24 21:44:37 christos Exp $       */
+/*     $NetBSD: hash.c,v 1.13 2003/11/25 19:34:05 rafal Exp $  */
 
 /*
  * Copyright (c) 1992, 1993
@@ -251,6 +251,8 @@
                if (hp->h_name != name)
                        continue;
                TAILQ_REMOVE(hpp, hp, h_next);
+
+               memset(hp, 0, sizeof(*hp));
                TAILQ_INSERT_TAIL(&hefreelist, hp, h_next);
                ht->ht_used--;
                return (0);
diff -r 422aa7f04437 -r ba113a01b9dd usr.sbin/config/util.c
--- a/usr.sbin/config/util.c    Tue Nov 25 19:05:46 2003 +0000
+++ b/usr.sbin/config/util.c    Tue Nov 25 19:34:05 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.19 2003/11/24 21:44:37 christos Exp $       */
+/*     $NetBSD: util.c,v 1.20 2003/11/25 19:34:06 rafal Exp $  */
 
 /*
  * Copyright (c) 1992, 1993
@@ -223,6 +223,7 @@
 nvfree(struct nvlist *nv)
 {
 
+       memset(nv, 0, sizeof(*nv));
        nv->nv_next = nvfreelist;
        nvfreelist = nv;
 }
@@ -237,6 +238,7 @@
 
        for (; nv != NULL; nv = next) {
                next = nv->nv_next;
+               memset(nv, 0, sizeof(*nv));
                nv->nv_next = nvfreelist;
                nvfreelist = nv;
        }



Home | Main Index | Thread Index | Old Index