From: Nick Porter Date: Thu, 4 Aug 2022 09:44:48 +0000 (+0100) Subject: Free tmpl_dcursor children in the correct order X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7211bbfc795d245552aa6f8e8fe13be481cad19a;p=thirdparty%2Ffreeradius-server.git Free tmpl_dcursor children in the correct order --- diff --git a/src/lib/server/tmpl_dcursor.c b/src/lib/server/tmpl_dcursor.c index 163e10d2502..92294c871e2 100644 --- a/src/lib/server/tmpl_dcursor.c +++ b/src/lib/server/tmpl_dcursor.c @@ -436,15 +436,15 @@ fr_pair_t *tmpl_dcursor_init(int *err, TALLOC_CTX *ctx, tmpl_dcursor_ctx_t *cc, void tmpl_dursor_clear(tmpl_dcursor_ctx_t *cc) { /* - * Always free the pool because it's allocated when - * any nested ctxs are used. + * If the pool wasn't created, nothing was talloc'd which + * needs freeing. */ - TALLOC_FREE(cc->pool); - - if (!fr_dlist_num_elements(&cc->nested)) return;/* Help simplify dealing with unused cursor ctxs */ + if (!cc->pool) return; fr_dlist_remove(&cc->nested, &cc->leaf); /* Noop if leaf isn't inserted */ fr_dlist_talloc_free(&cc->nested); + + TALLOC_FREE(cc->pool); }