]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove internal dictionary last.
authorAlan T. DeKok <aland@freeradius.org>
Sat, 3 Feb 2024 14:04:08 +0000 (09:04 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 3 Feb 2024 14:29:54 +0000 (09:29 -0500)
Many protocol dictionaries reference it.  If we try to remove it
first, it will still be referenced by them.  Instead, we want to
remove the protocol dictionaries first, and only then remove the
internal dictionary.

src/lib/util/dict_util.c

index e6c861a4a836baa07a8a9ede2f281c0118dac113..417e20479562339b682e6f882c6389e8c28620af 100644 (file)
@@ -3915,12 +3915,6 @@ static int _dict_global_free(fr_dict_gctx_t *gctx)
         */
        if (gctx->free_at_exit) fr_atexit_global_disarm(true, _dict_global_free_at_exit, gctx);
 
-       if (gctx->internal) {
-               dict_dependent_remove(gctx->internal, "global");        /* remove our dependency */
-
-               if (talloc_free(gctx->internal) < 0) still_loaded = true;
-       }
-
        /*
         *      Free up autorefs first, which will free up inter-dictionary dependencies.
         */
@@ -3946,12 +3940,23 @@ static int _dict_global_free(fr_dict_gctx_t *gctx)
                }
        }
 
+       /*
+        *      Free the internal dictionary as the last step, after all of the protocol dictionaries and
+        *      libraries have freed their references to it.
+        */
+       if (gctx->internal) {
+               dict_dependent_remove(gctx->internal, "global");        /* remove our dependency */
+
+               if (talloc_free(gctx->internal) < 0) still_loaded = true;
+       }
+
        if (still_loaded) {
 #ifndef NDEBUG
                fr_dict_global_ctx_debug(gctx);
 #endif
                return -1;
        }
+
        /*
         *      Set this to NULL just in case the caller tries to use
         *      dict_global_init() again.