From: Alan T. DeKok Date: Tue, 5 Apr 2022 14:44:26 +0000 (-0400) Subject: can't re-init structural types X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=003c73f3816b4454efd82a9c9441d821a8b0127d;p=thirdparty%2Ffreeradius-server.git can't re-init structural types where would the children go? Be freed? --- diff --git a/src/lib/util/pair.c b/src/lib/util/pair.c index b7aebba974..e2a503c7c4 100644 --- a/src/lib/util/pair.c +++ b/src/lib/util/pair.c @@ -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);