void *handle;
int (*init_fn) (void);
char *modulesdir;
+ int ret;
#ifdef HAVE_DLOPEN
if (getenv("LD_LDB_MODULE_PATH") != NULL) {
if (init_fn == NULL) {
ldb_debug(ldb, LDB_DEBUG_ERROR, "no symbol `init_module' found in %s: %s\n", path, dlerror());
+ dlclose(handle);
return -1;
}
talloc_free(path);
- return init_fn();
+ ret = init_fn();
+ if (ret == -1) {
+ dlclose(handle);
+ }
+ return ret;
#else
ldb_debug(ldb, LDB_DEBUG_TRACE, "no dlopen() - not trying to load %s module\n", name);
return -1;