From: Alan T. DeKok Date: Fri, 28 Nov 2025 17:18:59 +0000 (-0500) Subject: mark up where pairs were allocated from X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;p=thirdparty%2Ffreeradius-server.git mark up where pairs were allocated from we don't need to do this everywhere, but it's useful to do it for common cases. --- diff --git a/src/lib/server/tmpl_dcursor.c b/src/lib/server/tmpl_dcursor.c index eb7295f5f81..4fcc59abbad 100644 --- a/src/lib/server/tmpl_dcursor.c +++ b/src/lib/server/tmpl_dcursor.c @@ -563,7 +563,10 @@ fr_pair_t *tmpl_dcursor_pair_build(fr_pair_t *parent, fr_dcursor_t *cursor, fr_d { fr_pair_t *vp; vp = fr_pair_afrom_da(parent, da); - if (vp) fr_dcursor_append(cursor, vp); + if (vp) { + PAIR_ALLOCED(vp); + fr_dcursor_append(cursor, vp); + } return vp; } @@ -759,6 +762,7 @@ int tmpl_extents_build_to_leaf_parent(fr_dlist_head_t *existing, fr_dlist_head_t if (!fr_type_is_structural(ar->ar_da->type)) continue; MEM(vp = fr_pair_afrom_da(list_ctx, ar->ar_da)); /* Copies unknowns */ + PAIR_ALLOCED(vp); fr_pair_append(list, vp); list = &vp->vp_group; list_ctx = vp; /* New allocations occur under the VP */ diff --git a/src/lib/server/tmpl_eval.c b/src/lib/server/tmpl_eval.c index a7571286b7d..df0653680e0 100644 --- a/src/lib/server/tmpl_eval.c +++ b/src/lib/server/tmpl_eval.c @@ -828,6 +828,7 @@ int tmpl_find_or_add_vp(fr_pair_t **out, request_t *request, tmpl_t const *vpt) if (pair_append_by_tmpl_parent(ctx, &vp, head, vpt, true) < 0) return -1; + PAIR_ALLOCED(vp); *out = vp; } return 1; @@ -890,6 +891,7 @@ int pair_append_by_tmpl_parent(TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t */ if (!vp) { if (fr_pair_append_by_da(pair_ctx, &vp, list, ar->da) < 0) goto error; + PAIR_ALLOCED(vp); } /* diff --git a/src/lib/unlang/edit.c b/src/lib/unlang/edit.c index b3e03003d69..a1a6b420595 100644 --- a/src/lib/unlang/edit.c +++ b/src/lib/unlang/edit.c @@ -785,6 +785,8 @@ static int apply_edits_to_leaf(request_t *request, unlang_frame_state_edit_t *st } vp->op = map->op; + PAIR_ALLOCED(vp); + if (fr_value_box_cast(vp, &vp->data, vp->vp_type, vp->da, box) < 0) return -1; if (single) break; @@ -857,6 +859,7 @@ static int apply_edits_to_leaf(request_t *request, unlang_frame_state_edit_t *st if (fr_edit_list_insert_pair_tail(state->el, ¤t->lhs.vp_parent->vp_group, vp) < 0) goto fail; vp->op = T_OP_EQ; + PAIR_ALLOCED(vp); } goto done; @@ -945,6 +948,7 @@ static fr_pair_t *edit_list_pair_build(fr_pair_t *parent, fr_dcursor_t *cursor, current->lhs.vp_parent = parent; current->lhs.vp = vp; + PAIR_ALLOCED(vp); if (fr_edit_list_insert_pair_tail(current->el, &parent->vp_group, vp) < 0) { talloc_free(vp); @@ -1378,6 +1382,7 @@ static int check_lhs_nested(request_t *request, unlang_frame_state_edit_t *state MEM(current->lhs.vp = fr_pair_afrom_da(current->ctx, tmpl_attr_tail_da(current->lhs.vpt))); fr_pair_append(¤t->parent->rhs.pair_list, current->lhs.vp); current->lhs.vp->op = map->op; + PAIR_ALLOCED(current->lhs.vp); return expand_rhs(request, state, current); } diff --git a/src/lib/util/pair_legacy.c b/src/lib/util/pair_legacy.c index 6ffb9683056..788f23b4fd2 100644 --- a/src/lib/util/pair_legacy.c +++ b/src/lib/util/pair_legacy.c @@ -357,6 +357,7 @@ redo: if (!vp) return fr_sbuff_error(&our_in); + PAIR_ALLOCED(vp); PAIR_VERIFY(vp); /* @@ -434,11 +435,13 @@ redo: if (fr_pair_append_by_da(relative->ctx, &vp, relative->list, da) < 0) { return fr_sbuff_error(&our_in); } + PAIR_ALLOCED(vp); } } else { vp = fr_pair_afrom_da(relative->ctx, da); if (!vp) return fr_sbuff_error(&our_in); + PAIR_ALLOCED(vp); fr_pair_append(relative->list, vp); } @@ -480,6 +483,7 @@ redo: fr_dict_attr_unknown_free(&da_unknown); return fr_sbuff_error(&our_in); } + PAIR_ALLOCED(vp); fr_dict_attr_unknown_free(&da_unknown); @@ -510,6 +514,7 @@ redo: if (fr_pair_append_by_da(grand_vp, &vp, &grand_vp->vp_group, parent_vp->da) < 0) { return fr_sbuff_error(&our_in); } + PAIR_ALLOCED(vp); relative->ctx = vp; fr_assert(relative->da == vp->da); @@ -522,6 +527,7 @@ redo: vp = fr_pair_afrom_da_depth_nested(relative->ctx, relative->list, da, relative->da->depth); if (!vp) return fr_sbuff_error(&our_in); + PAIR_ALLOCED(vp); } fr_assert(vp != NULL); diff --git a/src/lib/util/pair_tokenize.c b/src/lib/util/pair_tokenize.c index b59f06805fb..08b15f75098 100644 --- a/src/lib/util/pair_tokenize.c +++ b/src/lib/util/pair_tokenize.c @@ -154,6 +154,7 @@ static fr_pair_t *fr_pair_afrom_fields(TALLOC_CTX *ctx, fr_dict_attr_t const *da if (!vp) return NULL; vp->op = op; + PAIR_ALLOCED(vp); if (fr_pair_value_from_str(vp, value, value_len, uerules, false) < 0) { talloc_free(vp); @@ -259,6 +260,7 @@ static ssize_t fr_pair_afrom_str(fr_pair_ctx_t *pair_ctx, char const *start, cha vp = fr_pair_afrom_fields(pair_ctx->ctx, da, op, value, value_len, fr_value_unescape_by_char[(uint8_t)quote]); if (!vp) return -(in - start); + PAIR_ALLOCED(vp); fr_pair_append(pair_ctx->list, vp); return p - start;