From: Arran Cudbard-Bell Date: Wed, 5 Jul 2017 20:23:29 +0000 (-0400) Subject: Free xlat_root when there are no registrations left X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a644d99649517e84fbfc2d367baa9e7f7d70ae8c;p=thirdparty%2Ffreeradius-server.git Free xlat_root when there are no registrations left --- diff --git a/src/main/xlat_func.c b/src/main/xlat_func.c index b5bc08bb1a3..e8ffedcffd7 100644 --- a/src/main/xlat_func.c +++ b/src/main/xlat_func.c @@ -820,6 +820,8 @@ void xlat_unregister(void *mod_inst, char const *name, UNUSED xlat_func_t func) if (c->mod_inst != mod_inst) return; rbtree_deletebydata(xlat_root, c); + + if (rbtree_num_elements(xlat_root) == 0) TALLOC_FREE(xlat_root); } static int xlat_unregister_callback(void *mod_inst, void *data) @@ -836,6 +838,8 @@ void xlat_unregister_module(void *instance) if (!xlat_root) return; /* All xlats have already been freed */ rbtree_walk(xlat_root, RBTREE_DELETE_ORDER, xlat_unregister_callback, instance); + + if (rbtree_num_elements(xlat_root) == 0) TALLOC_FREE(xlat_root); } /*