]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Free tmpl_dcursor children in the correct order
authorNick Porter <nick@portercomputing.co.uk>
Thu, 4 Aug 2022 09:44:48 +0000 (10:44 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Thu, 4 Aug 2022 11:14:59 +0000 (12:14 +0100)
src/lib/server/tmpl_dcursor.c

index 163e10d2502f2f24819a1ba481021ae97bd44ad0..92294c871e24eac0d25fe6ef4c63214c560c2e17 100644 (file)
@@ -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);
 }