]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
can't re-init structural types
authorAlan T. DeKok <aland@freeradius.org>
Tue, 5 Apr 2022 14:44:26 +0000 (10:44 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 7 Apr 2022 15:23:33 +0000 (11:23 -0400)
where would the children go?  Be freed?

src/lib/util/pair.c

index b7aebba9747b454ca166ff0ea42af536f391eeea..e2a503c7c431c1224357b71340e6196cba6dd969 100644 (file)
@@ -330,12 +330,19 @@ int fr_pair_reinit_from_da(fr_pair_list_t *list, fr_pair_t *vp, fr_dict_attr_t c
 {
        fr_dict_attr_t const *to_free;
 
+       /*
+        *      This only works for leaf nodes.
+        */
+       if (!fr_type_is_leaf(da->type)) return -1;
+
        /*
         *      vp may be created from fr_pair_alloc_null(), in which case it has no da.
         */
        if (vp->da) {
                if (vp->da == da) return 0;
 
+               if (!fr_type_is_leaf(vp->da->type)) return -1;
+
                if ((da->type != vp->da->type) && (fr_value_box_cast_in_place(vp, &vp->data, da->type, da) < 0)) return -1;
        } else {
                fr_value_box_init(&vp->data, da->type, da, false);