From: Alan T. DeKok Date: Fri, 29 Jul 2022 10:49:32 +0000 (-0400) Subject: allocate temporary VPs in the current context X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2376c526dc8fc03bd0c32b1d2e00c07c77c0ea7e;p=thirdparty%2Ffreeradius-server.git allocate temporary VPs in the current context and talloc_steal() them when we're keeping them. This is so that they will be automatically cleaned up on error. --- diff --git a/src/lib/unlang/edit.c b/src/lib/unlang/edit.c index 5c84e187cc9..2ef36b78260 100644 --- a/src/lib/unlang/edit.c +++ b/src/lib/unlang/edit.c @@ -565,12 +565,12 @@ static int apply_edits_to_leaf(request_t *request, edit_map_t *current, map_t co if (fr_pair_list_empty(¤t->rhs.pair_list)) return 0; - if (RDEBUG_ENABLED2) { - for (vp = fr_pair_list_head(¤t->rhs.pair_list); - vp != NULL; - vp = fr_pair_list_next(¤t->rhs.pair_list, vp)) { - RDEBUG2("%s %s %pV", current->lhs.vpt->name, fr_tokens[map->op], &vp->data); - } + for (vp = fr_pair_list_head(¤t->rhs.pair_list); + vp != NULL; + vp = fr_pair_list_next(¤t->rhs.pair_list, vp)) { + (void) talloc_steal(current->lhs.vp_parent, vp); + + RDEBUG2("%s %s %pV", current->lhs.vpt->name, fr_tokens[map->op], &vp->data); } if (fr_edit_list_insert_list_tail(current->el, ¤t->lhs.vp_parent->vp_group, @@ -724,7 +724,7 @@ redo: fr_assert(current->parent); fr_assert(current->parent->lhs.vp_parent != NULL); - MEM(vp = fr_pair_afrom_da(current->parent->lhs.vp_parent, current->parent->lhs.vp->da)); + MEM(vp = fr_pair_afrom_da(current, current->parent->lhs.vp->da)); /* * @todo - handle lists from xlats?