From: Nick Porter Date: Wed, 6 Sep 2023 11:26:52 +0000 (+0100) Subject: Insert new pair where we were asked to X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e68f0d60ff1270e5c1497cacb2308827cd5c98d2;p=thirdparty%2Ffreeradius-server.git Insert new pair where we were asked to --- diff --git a/src/lib/util/pair.c b/src/lib/util/pair.c index 6467f58dc22..8d8b10a38b5 100644 --- a/src/lib/util/pair.c +++ b/src/lib/util/pair.c @@ -3498,7 +3498,15 @@ static fr_pair_t *pair_alloc_parent(fr_pair_t *in, fr_pair_t *item, fr_dict_attr vp = fr_pair_afrom_da(parent, da); if (!vp) return NULL; - fr_pair_append(&parent->vp_group, vp); + /* + * If we are at the root, and have been provided with + * an entry to insert before, then do that. + */ + if (item && da->parent->flags.is_root) { + fr_pair_insert_before(&parent->vp_group, item, vp); + } else { + fr_pair_append(&parent->vp_group, vp); + } return vp; }