free_dict_attr should set pointer to NULL after freeing
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 12 Feb 2013 22:38:17 +0000 (17:38 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 12 Feb 2013 22:38:17 +0000 (17:38 -0500)
src/include/libradius.h
src/lib/dict.c

index be7f44f..e723484 100644 (file)
@@ -280,7 +280,7 @@ int         dict_addattr(const char *name, int attr, unsigned int vendor, int type, ATT
 int            dict_addvalue(const char *namestr, const char *attrstr, int value);
 int            dict_init(const char *dir, const char *fn);
 void           dict_free(void);
-void           dict_attr_free(const DICT_ATTR *da);
+void           dict_attr_free(DICT_ATTR * const *da);
 const DICT_ATTR        *dict_attr_copy(const DICT_ATTR *da);
 const DICT_ATTR        *dict_attrunknown(unsigned int attr, unsigned int vendor);
 const DICT_ATTR        *dict_attrunknownbyname(const char *attribute);
index 5c7d777..0e0a3cf 100644 (file)
@@ -2454,17 +2454,19 @@ static size_t print_attr_oid(char *buffer, size_t size, unsigned int attr,
  *
  * @param da to free.
  */
-void dict_attr_free(const DICT_ATTR *da)
+void dict_attr_free(DICT_ATTR * const *da)
 {
-       DICT_ATTR *tmp;
+       DICT_ATTR **tmp;
        
        /* Don't free real DAs */
-       if (!da->flags.is_unknown) {
+       if (!(*da)->flags.is_unknown) {
                return;
        }
        
-       memcpy(&tmp, &da, sizeof(tmp));
-       free(tmp);      
+       memcpy(&tmp, &da, sizeof(*tmp));
+       free(*tmp);
+       
+       *tmp = NULL;    
 }
 
 /** Copies a dictionary attr