From: Alan T. DeKok Date: Fri, 13 May 2022 21:48:39 +0000 (-0400) Subject: don't free too much X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=350de16d4cc435cf3da475591ab17080e6bf807f;p=thirdparty%2Ffreeradius-server.git don't free too much --- diff --git a/src/bin/unit_test_attribute.c b/src/bin/unit_test_attribute.c index dc05a05a37c..69827bf82ca 100644 --- a/src/bin/unit_test_attribute.c +++ b/src/bin/unit_test_attribute.c @@ -2789,7 +2789,7 @@ static size_t command_xlat_argv(command_result_t *result, command_file_ctx_t *cc RETURN_OK_WITH_ERROR(); } - argc = xlat_flatten_compiled_argv(cc->tmp_ctx, &argv, &head); + argc = xlat_flatten_compiled_argv(cc->tmp_ctx, &argv, head); if (argc <= 0) { fr_strerror_printf_push("ERROR in argument %d", (int) -argc); RETURN_OK_WITH_ERROR(); diff --git a/src/lib/unlang/xlat.h b/src/lib/unlang/xlat.h index 85509250dc8..18cd8ea6825 100644 --- a/src/lib/unlang/xlat.h +++ b/src/lib/unlang/xlat.h @@ -286,7 +286,7 @@ ssize_t xlat_aeval_compiled(TALLOC_CTX *ctx, char **out, request_t *request, int xlat_aeval_compiled_argv(TALLOC_CTX *ctx, char ***argv, request_t *request, xlat_exp_head_t const *head, xlat_escape_legacy_t escape, void const *escape_ctx); -int xlat_flatten_compiled_argv(TALLOC_CTX *ctx, xlat_exp_head_t ***argv, xlat_exp_head_t **head); +int xlat_flatten_compiled_argv(TALLOC_CTX *ctx, xlat_exp_head_t ***argv, xlat_exp_head_t *head); bool xlat_async_required(xlat_exp_head_t const *xlat); diff --git a/src/lib/unlang/xlat_eval.c b/src/lib/unlang/xlat_eval.c index 15089314576..4ac3d2271a8 100644 --- a/src/lib/unlang/xlat_eval.c +++ b/src/lib/unlang/xlat_eval.c @@ -1646,14 +1646,14 @@ int xlat_aeval_compiled_argv(TALLOC_CTX *ctx, char ***argv, request_t *request, * * This is mostly for async use. */ -int xlat_flatten_compiled_argv(TALLOC_CTX *ctx, xlat_exp_head_t ***argv, xlat_exp_head_t **head) +int xlat_flatten_compiled_argv(TALLOC_CTX *ctx, xlat_exp_head_t ***argv, xlat_exp_head_t *head) { int i; xlat_exp_head_t **my_argv; size_t count; count = 0; - xlat_exp_foreach(*head, node) { + xlat_exp_foreach(head, node) { count++; } @@ -1663,13 +1663,12 @@ int xlat_flatten_compiled_argv(TALLOC_CTX *ctx, xlat_exp_head_t ***argv, xlat_ex fr_assert(done_init); i = 0; - xlat_exp_foreach(*head, node) { + xlat_exp_foreach(head, node) { fr_assert(node->type == XLAT_GROUP); my_argv[i++] = talloc_steal(my_argv, node->group); } - talloc_free(*head); - *head = NULL; + fr_dlist_talloc_free(&head->dlist); return count; } diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index 84c3858bedc..bf8dfca2f9d 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -325,7 +325,7 @@ static int xlat_logical_instantiate(xlat_inst_ctx_t const *xctx) { xlat_logical_inst_t *inst = talloc_get_type_abort(xctx->inst, xlat_logical_inst_t); - inst->argc = xlat_flatten_compiled_argv(inst, &inst->argv, &xctx->ex->call.args); + inst->argc = xlat_flatten_compiled_argv(inst, &inst->argv, xctx->ex->call.args); inst->sense = (xctx->ex->call.func->token == T_LOR); return 0;