Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/gen Ensure that we don't try to free random memory ...



details:   https://anonhg.NetBSD.org/src/rev/f5f7c7e90ec0
branches:  trunk
changeset: 581376:f5f7c7e90ec0
user:      lukem <lukem%NetBSD.org@localhost>
date:      Wed Jun 01 05:30:54 2005 +0000

description:
Ensure that we don't try to free random memory when another malloc fails,
by initializing newprepare, newparent, and newchild to NULL.
Detected by gcc -Wuninitialized.

diffstat:

 lib/libc/gen/pthread_atfork.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r 8502cb54b73e -r f5f7c7e90ec0 lib/libc/gen/pthread_atfork.c
--- a/lib/libc/gen/pthread_atfork.c     Wed Jun 01 05:24:54 2005 +0000
+++ b/lib/libc/gen/pthread_atfork.c     Wed Jun 01 05:30:54 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_atfork.c,v 1.3 2004/10/21 06:46:36 lukem Exp $ */
+/*     $NetBSD: pthread_atfork.c,v 1.4 2005/06/01 05:30:54 lukem Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: pthread_atfork.c,v 1.3 2004/10/21 06:46:36 lukem Exp $");
+__RCSID("$NetBSD: pthread_atfork.c,v 1.4 2005/06/01 05:30:54 lukem Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #define __LIBC12_SOURCE__
@@ -82,6 +82,8 @@
 {
        struct atfork_callback *newprepare, *newparent, *newchild;
 
+       newprepare = newparent = newchild = NULL;
+
        if (prepare != NULL) {
                newprepare = malloc(sizeof(struct atfork_callback));
                if (newprepare == NULL)



Home | Main Index | Thread Index | Old Index