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.
This commit is contained in:
parent
b8fe389b4c
commit
d999a32485
@ -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 @@ pthread_atfork(void (*prepare)(void), void (*parent)(void),
|
||||
{
|
||||
struct atfork_callback *newprepare, *newparent, *newchild;
|
||||
|
||||
newprepare = newparent = newchild = NULL;
|
||||
|
||||
if (prepare != NULL) {
|
||||
newprepare = malloc(sizeof(struct atfork_callback));
|
||||
if (newprepare == NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user