]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix crash on exit
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 3 Nov 2021 18:55:26 +0000 (14:55 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 3 Nov 2021 18:55:26 +0000 (14:55 -0400)
src/modules/rlm_ldap/rlm_ldap.c

index 45c2794e5b34ab2c7cf8f3ce53747f2a21cd6bc2..53659c0995b78dfb0a4389a86be1952399fba992 100644 (file)
@@ -1810,15 +1810,15 @@ static int mod_thread_instatiate(UNUSED CONF_SECTION const *conf, void *instance
 static int mod_thread_detach(UNUSED fr_event_list_t *el, void *thread)
 {
        fr_ldap_thread_t        *this_thread = thread;
-       fr_ldap_thread_trunk_t  *ttrunk;
-       fr_rb_iter_preorder_t   iter;
+       void                    **trunks_to_free;
+       int                     i;
 
-       for (ttrunk = fr_rb_iter_init_preorder(&iter, this_thread->trunks);
-            ttrunk;
-            ttrunk = fr_rb_iter_next_preorder(&iter)) {
-               talloc_free(ttrunk->trunk);
-       }
+       if (fr_rb_flatten_inorder(NULL, &trunks_to_free, this_thread->trunks) < 0) return -1;
+
+       for (i = talloc_array_length(trunks_to_free); i >= 0; i--) talloc_free(trunks_to_free[i]);
+       talloc_free(trunks_to_free);
        talloc_free(this_thread->trunks);
+
        return 0;
 }