lib: ldb: Use NULL to allocate modules not talloc_autofree_context().
authorJeremy Allison <jra@samba.org>
Mon, 24 Jul 2017 19:11:03 +0000 (12:11 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 26 Jul 2017 19:35:21 +0000 (21:35 +0200)
ldb modules are not (yet) unloaded and are only loaded once (there is a check
that makes sure of this). Allocate off the NULL context. We never want this
to be freed until process shutdown. If eventually we add the ability to
unload ldb modules we can add a deregister function that walks and frees the list.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12932

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/common/ldb_modules.c

index 3dd0438c1281c1e613d9dd3ab79763a8cd1a4771..25551e1a2edf29ce7ffda36d8e9f093f40adc836 100644 (file)
@@ -280,7 +280,17 @@ int ldb_register_module(const struct ldb_module_ops *ops)
        if (ldb_find_module_ops(ops->name) != NULL)
                return LDB_ERR_ENTRY_ALREADY_EXISTS;
 
-       entry = talloc(talloc_autofree_context(), struct ops_list_entry);
+       /*
+        * ldb modules are not (yet) unloaded and
+        * are only loaded once (the above check
+        * makes sure of this). Allocate off the NULL
+        * context. We never want this to be freed
+        * until process shutdown. If eventually we
+        * want to unload ldb modules we can add a
+        * deregister function that walks and
+        * frees the list.
+        */
+       entry = talloc(NULL, struct ops_list_entry);
        if (entry == NULL) {
                return LDB_ERR_OPERATIONS_ERROR;
        }