]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
no need to pass "func" to xlat_purify_expr()
authorAlan T. DeKok <aland@freeradius.org>
Thu, 20 Jan 2022 16:34:14 +0000 (11:34 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 20 Jan 2022 16:34:14 +0000 (11:34 -0500)
src/lib/unlang/xlat_expr.c

index b53ea178482c80ea8e2ee230ca831a758f172448..c90e1e8ffcca2f31df5ec307bab5a236586d9fa8 100644 (file)
@@ -115,9 +115,10 @@ static void cast_to_bool(fr_value_box_t *out, fr_value_box_t const *in)
 /** Basic purify, but only for expressions and comparisons.
  *
  */
-static int xlat_purify_expr(xlat_exp_t *node, xlat_t *func)
+static int xlat_purify_expr(xlat_exp_t *node)
 {
        int rcode = -1;
+       xlat_t const *func;
        xlat_exp_t *child;
        fr_value_box_t *dst = NULL, *box;
        xlat_arg_parser_t const *arg;
@@ -125,10 +126,12 @@ static int xlat_purify_expr(xlat_exp_t *node, xlat_t *func)
        fr_value_box_list_t input, output;
        fr_dcursor_t cursor;
 
-       if (!func || (node->type != XLAT_FUNC)) return 0;
+       if (node->type != XLAT_FUNC) return 0;
 
        if (!node->flags.pure) return 0;
 
+       func = node->call.func;
+
        if (!func->internal) return 0;
 
        if (func->token == T_INVALID) return 0;
@@ -948,6 +951,16 @@ done:
        }
 
 check_unary:
+       /*
+        *      Purify things in place, where we can.
+        */
+       if (flags->pure) {
+               if (xlat_purify_expr(node) < 0) {
+                       talloc_free(node);
+                       FR_SBUFF_ERROR_RETURN(&in); /* @todo m_lhs ? */
+               }
+       }
+
        /*
         *      @todo - purify the node.
         */
@@ -1170,7 +1183,7 @@ redo:
         *      Purify things in place, where we can.
         */
        if (flags->pure) {
-               if (xlat_purify_expr(node, func) < 0) {
+               if (xlat_purify_expr(node) < 0) {
                        talloc_free(node);
                        FR_SBUFF_ERROR_RETURN(&in); /* @todo m_lhs ? */
                }