Skip to content

Commit

Permalink
delete old attributes every time through the loop
Browse files Browse the repository at this point in the history
and minor cleanups
  • Loading branch information
alandekok committed Sep 3, 2024
1 parent 7421b4e commit 342658b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/lib/unlang/foreach.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -178,6 +184,8 @@ static unlang_action_t unlang_foreach_next(rlm_rcode_t *p_result, request_t *req
* 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;
Expand Down

0 comments on commit 342658b

Please sign in to comment.