]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
resolve function arguments before the function itself
authorAlan T. DeKok <aland@freeradius.org>
Fri, 20 May 2022 13:41:38 +0000 (09:41 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 20 May 2022 16:09:02 +0000 (12:09 -0400)
otherwise the function may steal the arguments into its internal
structures, where they cannot be resolved.

src/lib/unlang/xlat_eval.c

index 26f41340330315a5de6beea3de11098f6a6294aa..0a2df92f0dbacd6bb5530c4b04ab0a7a54ab540e 100644 (file)
@@ -1700,18 +1700,20 @@ int xlat_eval_walk(xlat_exp_head_t *head, xlat_walker_t walker, xlat_type_t type
        xlat_exp_foreach(head, node) {
                switch (node->type){
                case XLAT_FUNC:
-                       if (!type || (type & XLAT_FUNC)) {
-                               ret = walker(node, uctx);
-                               if (ret < 0) return ret;
-                       }
-
                        /*
-                        *      Now evaluate the function's arguments
+                        *      Evaluate the function's arguments
+                        *      first, as they may get moved around
+                        *      when the function is instantiated.
                         */
                        if (xlat_exp_head(node->call.args)) {
                                ret = xlat_eval_walk(node->call.args, walker, type, uctx);
                                if (ret < 0) return ret;
                        }
+
+                       if (!type || (type & XLAT_FUNC)) {
+                               ret = walker(node, uctx);
+                               if (ret < 0) return ret;
+                       }
                        break;
 
                case XLAT_FUNC_UNRESOLVED: