]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
it helps to parent things properly
authorAlan T. DeKok <aland@freeradius.org>
Mon, 17 Mar 2025 03:08:06 +0000 (10:08 +0700)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 17 Mar 2025 04:26:53 +0000 (11:26 +0700)
src/lib/unlang/xlat_expr.c

index 168617c2a288d7b37661887e11a7745e5fe02f53..917012285758dd36c3e5a442c1e6b1a9f9d747e2 100644 (file)
@@ -2167,7 +2167,7 @@ static fr_slen_t tokenize_unary(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf
  *  See xlat_func_cast() for the implementation.
  *
  */
-static xlat_exp_t *expr_cast_alloc(TALLOC_CTX *ctx, fr_type_t type)
+static xlat_exp_t *expr_cast_alloc(TALLOC_CTX *ctx, fr_type_t type, xlat_exp_t *child)
 {
        xlat_exp_t *cast, *node;
 
@@ -2198,6 +2198,8 @@ static xlat_exp_t *expr_cast_alloc(TALLOC_CTX *ctx, fr_type_t type)
        node->data.vb_uint8 = type;
 
        xlat_func_append_arg(cast, node, false);
+       (void) talloc_steal(cast, child);
+       xlat_func_append_arg(cast, child, false);
 
        return cast;
 }
@@ -2795,8 +2797,7 @@ done:
        if (cast_type != FR_TYPE_NULL) {
                xlat_exp_t *cast;
 
-               MEM(cast = expr_cast_alloc(head, cast_type));
-               xlat_func_append_arg(cast, node, false);
+               MEM(cast = expr_cast_alloc(head, cast_type, node));
                node = cast;
        }