]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Reference count dl modules from 1
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 27 May 2024 03:04:11 +0000 (23:04 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 27 May 2024 03:04:11 +0000 (23:04 -0400)
src/lib/server/dl_module.c

index 7d1096c0eb72405220de34852f75708821c9686d..6f7f591561472e8210eeee2fe2c9ac50ce5d5ba3 100644 (file)
@@ -243,10 +243,7 @@ static int _dl_module_free(dl_module_t *dl_module)
        /*
         *      Decrement refcounts, freeing at zero
         */
-       if (dl_module->refs > 0) {
-               dl_module->refs--;
-               return -1;
-       }
+       if (--dl_module->refs > 0) return -1;
 
        /*
         *      dl is empty if we tried to load it and failed.
@@ -364,6 +361,7 @@ dl_module_t *dl_module_alloc(dl_module_t const *parent, char const *name, dl_mod
        dl_module->loader = dl_module_loader;
        dl_module->parent = parent;
        dl_module->type = type;
+       dl_module->refs = 1;
        talloc_set_destructor(dl_module, _dl_module_free);      /* Do this late */
 
        /*