From: Alan T. DeKok Date: Wed, 15 Dec 2021 14:47:52 +0000 (-0500) Subject: make fr_edit_list_insert_list_after() work for !el situation X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6e170737cd2414666e5aec179e7e007b0fd1aaf;p=thirdparty%2Ffreeradius-server.git make fr_edit_list_insert_list_after() work for !el situation --- diff --git a/src/lib/util/edit.c b/src/lib/util/edit.c index 3581735ccb..e088c86baf 100644 --- a/src/lib/util/edit.c +++ b/src/lib/util/edit.c @@ -537,7 +537,7 @@ static int _edit_list_destructor(fr_edit_list_t *el) { fr_edit_t *e; - if (!el) return 0; + fr_assert(el != NULL); for (e = fr_dlist_head(&el->list); e != NULL; @@ -633,10 +633,22 @@ int fr_edit_list_insert_list_after(fr_edit_list_t *el, fr_pair_list_t *list, fr_ { fr_pair_t *prev, *vp; - if (!el) return 0; - prev = pos; + if (!el) { + /* + * @todo - this should really be an O(1) dlist + * operation. + */ + while ((vp = fr_pair_list_head(to_insert)) != NULL) { + (void) fr_pair_remove(to_insert, vp); + (void) fr_pair_insert_after(list, prev, vp); + prev = vp; + } + + return 0; + } + /* * We have to record each individual insert as a separate * item. Some later edit may insert pairs in the middle