From: Ted Lemon Date: Thu, 27 May 1999 12:38:05 +0000 (+0000) Subject: Fix up some more POINTER_DEBUG cases to prevent core dumps. X-Git-Tag: V3-ALPHA-19990527~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=203eccaeb5ccbbce17f870e25f34ad72504161d1;p=thirdparty%2Fdhcp.git Fix up some more POINTER_DEBUG cases to prevent core dumps. --- diff --git a/common/alloc.c b/common/alloc.c index 481c3311a..84aabc2db 100644 --- a/common/alloc.c +++ b/common/alloc.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: alloc.c,v 1.29 1999/05/07 17:34:30 mellon Exp $ Copyright (c) 1995, 1996, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: alloc.c,v 1.30 1999/05/27 12:38:05 mellon Exp $ Copyright (c) 1995, 1996, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -483,7 +483,7 @@ int expression_reference (ptr, src, name) #if defined (POINTER_DEBUG) abort (); #else - return 0; + *ptr = (struct expression *)0; #endif } *ptr = src; @@ -531,7 +531,7 @@ int option_cache_reference (ptr, src, name) #if defined (POINTER_DEBUG) abort (); #else - return 0; + *ptr = (struct option_cache *)0; #endif } *ptr = src; @@ -573,7 +573,7 @@ int buffer_reference (ptr, bp, name) #if defined (POINTER_DEBUG) abort (); #else - return 0; + *ptr = (struct buffer *)0; #endif } *ptr = bp; @@ -587,7 +587,7 @@ int buffer_dereference (ptr, name) { struct buffer *bp; - if (!ptr || !*ptr) { + if (!ptr) { log_error ("Null pointer passed to buffer_dereference: %s", name); #if defined (POINTER_DEBUG) @@ -597,6 +597,15 @@ int buffer_dereference (ptr, name) #endif } + if (!*ptr) { + log_error ("Null pointer in buffer_dereference: %s", name); +#if defined (POINTER_DEBUG) + abort (); +#else + return 0; +#endif + } + (*ptr) -> refcnt--; if (!(*ptr) -> refcnt) dfree ((*ptr), name); @@ -640,7 +649,7 @@ int dns_host_entry_reference (ptr, bp, name) #if defined (POINTER_DEBUG) abort (); #else - return 0; + *ptr = (struct dns_host_entry *)0; #endif } *ptr = bp; @@ -692,7 +701,7 @@ int option_state_allocate (ptr, name) #if defined (POINTER_DEBUG) abort (); #else - return 0; + *ptr = (struct option_state *)0; #endif } @@ -727,7 +736,7 @@ int option_state_reference (ptr, bp, name) #if defined (POINTER_DEBUG) abort (); #else - return 0; + *ptr = (struct option_state *)0; #endif } *ptr = bp;