From: Alan T. DeKok Date: Sun, 1 Oct 2023 14:25:26 +0000 (-0400) Subject: we can't in general copy xlats. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23bf72ffc8d92a23fc10e560c0255a15c9d5bbaf;p=thirdparty%2Ffreeradius-server.git we can't in general copy xlats. because they need resolving. And copying an xlat means that the xlat does not appear in the instance tree --- diff --git a/src/lib/server/tmpl_tokenize.c b/src/lib/server/tmpl_tokenize.c index 1978ddaf483..6202f479c81 100644 --- a/src/lib/server/tmpl_tokenize.c +++ b/src/lib/server/tmpl_tokenize.c @@ -3379,9 +3379,17 @@ tmpl_t *tmpl_copy(TALLOC_CTX *ctx, tmpl_t const *in) } /* - * Copy the xlat component + * Copy the xlat component. + * + * @todo - in general we can't copy an xlat, as the instances need resolving! + * + * We add an assertion here because nothing allocates the head, and we need it. */ - if (tmpl_contains_xlat(vpt) && unlikely(xlat_copy(vpt, vpt->data.xlat.ex, in->data.xlat.ex) < 0)) goto error; + if (tmpl_contains_xlat(vpt)) { + fr_assert(vpt->data.xlat.ex != NULL); + + if (unlikely(xlat_copy(vpt, vpt->data.xlat.ex, in->data.xlat.ex) < 0)) goto error; + } return vpt; }