]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
delete old attributes every time through the loop
authorAlan T. DeKok <aland@freeradius.org>
Tue, 3 Sep 2024 18:59:38 +0000 (14:59 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 3 Sep 2024 19:05:27 +0000 (15:05 -0400)
and minor cleanups

src/lib/unlang/foreach.c

index 50894e8ed0f15f0279e0685a34a46e72497aaf9e..e49dec138d263f1ecd459991070d837f5512db5e 100644 (file)
@@ -159,10 +159,16 @@ static unlang_action_t unlang_foreach_next(rlm_rcode_t *p_result, request_t *req
         *      check the "immutable" flag.  That flag is for the people using unlang, not for the
         *      interpreter.
         */
-       if (!fr_type_is_structural(vp->vp_type) && (vp->vp_type == state->key->vp_type)) {
-               fr_value_box_clear_value(&vp->data);
-               (void) fr_value_box_copy(vp, &vp->data, &state->key->data);
-       }       
+       if (fr_type_is_leaf(vp->vp_type)) {
+               if (vp->vp_type == state->key->vp_type) {
+                       fr_value_box_clear_value(&vp->data);
+                       (void) fr_value_box_copy(vp, &vp->data, &state->key->data);
+               }
+       } else {
+               /*
+                *      @todo - copy the pairs back?
+                */
+       }
 
 next:
        vp = fr_dcursor_next(&state->cursor);
@@ -178,6 +184,8 @@ next:
         *      Copy the data.
         */
        if (fr_type_is_structural(vp->vp_type)) {
+               fr_pair_list_free(&state->key->vp_group);
+
                if (fr_pair_list_copy(state->key, &state->key->vp_group, &vp->vp_group) < 0) {
                        REDEBUG("Failed copying children of %s", state->key->da->name);
                        *p_result = RLM_MODULE_FAIL;