From: Alan T. DeKok Date: Fri, 20 May 2022 13:41:38 +0000 (-0400) Subject: resolve function arguments before the function itself X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6190a99069b1af8ff706cdacf28063ae58e48044;p=thirdparty%2Ffreeradius-server.git resolve function arguments before the function itself otherwise the function may steal the arguments into its internal structures, where they cannot be resolved. --- diff --git a/src/lib/unlang/xlat_eval.c b/src/lib/unlang/xlat_eval.c index 26f41340330..0a2df92f0db 100644 --- a/src/lib/unlang/xlat_eval.c +++ b/src/lib/unlang/xlat_eval.c @@ -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: