From: Alan T. DeKok Date: Wed, 1 Feb 2023 13:34:07 +0000 (-0500) Subject: let's not use vpt after it's been freed X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18ff2a3a0b996e08ad2d92057b81521d71641614;p=thirdparty%2Ffreeradius-server.git let's not use vpt after it's been freed and clean up some of the other code to avoid leaks on error --- diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index 4ab5f739366..bcffca921ea 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -2361,18 +2361,7 @@ static fr_slen_t tokenize_field(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf } talloc_free(vpt); - - } else { - /* - * Else we're not hoisting, set the node to the VPT - */ - node->vpt = vpt; - node->quote = quote; - node->fmt = vpt->name; - - node->flags.pure = tmpl_is_data(node->vpt); - node->flags.constant = node->flags.pure; - node->flags.needs_resolving = tmpl_needs_resolving(node->vpt); + goto done; } /* @@ -2381,7 +2370,6 @@ static fr_slen_t tokenize_field(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf * to the same da. */ if (tmpl_is_attr(vpt)) { - fr_assert(!node->flags.pure); if (tmpl_attr_unknown_add(vpt) < 0) { fr_strerror_printf("Failed defining attribute %s", tmpl_attr_tail_da(vpt)->name); fr_sbuff_set(&our_in, &opand_m); @@ -2389,6 +2377,17 @@ static fr_slen_t tokenize_field(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf } } + /* + * Else we're not hoisting, set the node to the VPT + */ + node->vpt = vpt; + node->quote = quote; + node->fmt = vpt->name; + + node->flags.pure = tmpl_is_data(node->vpt); + node->flags.constant = node->flags.pure; + node->flags.needs_resolving = tmpl_needs_resolving(node->vpt); + if (tmpl_is_data(vpt)) { /* * Print "true" and "false" instead of "yes" and "no".