]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Swap cursor functions for list functions in map_list_mod_to_vps()
authorNick Porter <nick@portercomputing.co.uk>
Tue, 22 Dec 2020 16:59:50 +0000 (16:59 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 21 Jan 2021 23:05:49 +0000 (23:05 +0000)
src/lib/server/map_async.c

index 6ac53a7bf5caccf62971055ab7d0a4fd51ba084a..05909f66bee67636d12f3b416699889bceee2f9b 100644 (file)
@@ -806,7 +806,6 @@ static fr_pair_list_t map_list_mod_to_vps(TALLOC_CTX *ctx, vp_list_mod_t const *
 {
        map_t   *mod;
        fr_pair_list_t  head;
-       fr_cursor_t     cursor;
 
        fr_pair_list_init(&head);
        fr_assert(vlm->mod);
@@ -815,13 +814,15 @@ static fr_pair_list_t map_list_mod_to_vps(TALLOC_CTX *ctx, vp_list_mod_t const *
         *      Fast path...
         */
        if (!vlm->mod->next && !tmpl_value(vlm->mod->rhs)->next) {
-               return map_list_mod_to_vp(ctx, vlm->mod->lhs, tmpl_value(vlm->mod->rhs));
+               fr_pair_t *vp;
+               vp = map_list_mod_to_vp(ctx, vlm->mod->lhs, tmpl_value(vlm->mod->rhs));
+               fr_pair_add(&head, vp);
+               return head;
        }
 
        /*
         *      Slow path.  This may generate multiple attributes.
         */
-       fr_cursor_init(&cursor, &head);
        for (mod = vlm->mod;
             mod;
             mod = mod->next) {
@@ -833,11 +834,10 @@ static fr_pair_list_t map_list_mod_to_vps(TALLOC_CTX *ctx, vp_list_mod_t const *
                     vb = vb->next) {
                        vp = map_list_mod_to_vp(ctx, mod->lhs, vb);
                        if (!vp) {
-                               fr_cursor_head(&cursor);
-                               fr_cursor_free_list(&cursor);
-                               return NULL;
+                               fr_pair_list_free(&head);
+                               return head;
                        }
-                       fr_cursor_append(&cursor, vp);
+                       fr_pair_add(&head, vp);
                }
        }