NetBSD-Bugs archive

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

Re: lib/43964: prop_dictionary_equals(3) fails with Segmentation fault



The following reply was made to PR lib/43964; it has been noted by GNATS.

From: Jukka Ruohonen <jruohonen%iki.fi@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: lib/43964: prop_dictionary_equals(3) fails with Segmentation fault
Date: Wed, 6 Apr 2011 20:20:00 +0300

 On Tue, Oct 12, 2010 at 10:40:01PM +0000, dyoung%ojctech.com@localhost wrote:
 > prop_dictionary_equals(3) fails with a Segmentation fault.  Perhaps it's
 > calling through a NULL function pointer?  Backtrace from gdb:
 
 Indeed it is a NULL pointer deref; in your test case 'd' is a valid
 dictionary but 'od' is NULL so the following segfaults
 
        prop_dictionary_equals(d, NULL);
 
 as
 
 bool
 prop_dictionary_equals(prop_dictionary_t dict1, prop_dictionary_t dict2)
 {
         if (!prop_object_is_dictionary(dict1) ||
             !prop_object_is_dictionary(dict2))
                 return (false);
 
         return (prop_object_equals(dict1, dict2));
 }
 
 and prop_object_is_dictionary() is a macro defined as
 
 #define prop_object_is_dictionary(x)            \
         ((x) != NULL && (x)->pd_obj.po_type == &_prop_object_type_dictionary)
 
 I don't know about the design choices of proplib(3), but it seems that the
 API is not meant to check for NULL pointers and thus this is sort of PEBKAC...
 


Home | Main Index | Thread Index | Old Index