]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
don't free too much
authorAlan T. DeKok <aland@freeradius.org>
Fri, 13 May 2022 21:48:39 +0000 (17:48 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 16 May 2022 19:00:24 +0000 (15:00 -0400)
src/bin/unit_test_attribute.c
src/lib/unlang/xlat.h
src/lib/unlang/xlat_eval.c
src/lib/unlang/xlat_expr.c

index dc05a05a37c5c574a4494bb542243ebea3ef2da7..69827bf82caf5a8c38891dd57f0343eaa8a384a9 100644 (file)
@@ -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();
index 85509250dc8253c53a595dfdf8a97820537e7fca..18cd8ea6825c4068e3290ef1ce591b5adc03e089 100644 (file)
@@ -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);
 
index 150893145765269affa049e54cc5da95ce081ad9..4ac3d2271a85cd1e828c105fb7ea1a22830fe00b 100644 (file)
@@ -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;
 }
index 84c3858bedc62cbfc4fdb6889cd8c182def01b46..bf8dfca2f9d9d8857a5da95efa3ba0a3195b05da 100644 (file)
@@ -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;