]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
use correct order for talloc_link_ctx() to avoid leaks
authorAlan T. DeKok <aland@freeradius.org>
Thu, 28 May 2026 13:44:26 +0000 (09:44 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 28 May 2026 13:44:26 +0000 (09:44 -0400)
src/lib/unlang/xlat_func.c

index 479af53120545b6e3c4d94569a2f6268bfdc54e1..33e5e211949cb59abb9dad60550f6315b5ae7bfa 100644 (file)
@@ -271,8 +271,10 @@ xlat_t *xlat_func_register(TALLOC_CTX *ctx, char const *name, xlat_func_t func,
         *      Don't allocate directly in the parent ctx, it might be mprotected
         *      later, and that'll cause segfaults if any of the xlat_t are still
         *      protected when we start shuffling the contents of the rbtree.
+        *
+        *      But we do want "c" to be freed when "ctx" is freed.
         */
-       if (ctx) talloc_link_ctx(c, ctx);
+       if (ctx) talloc_link_ctx(ctx, c);
 
        talloc_set_destructor(c, _xlat_func_talloc_free);
        DEBUG3("%s: %s", __FUNCTION__, c->name);