summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-06-13 16:05:31 +0200
committerVolker Lendecke <vl@samba.org>2008-06-13 16:15:12 +0200
commit1bc1b1ac0af4baef266e3f9ea9adb7d8d252cc03 (patch)
tree6a29519bda47be52f8411b444a6cb8592db3288d /source3
parentc404c8950d4c4a5ab56e5a1b7b895403cfa0ea18 (diff)
downloadsamba-1bc1b1ac0af4baef266e3f9ea9adb7d8d252cc03.tar.gz
samba-1bc1b1ac0af4baef266e3f9ea9adb7d8d252cc03.tar.bz2
samba-1bc1b1ac0af4baef266e3f9ea9adb7d8d252cc03.zip
Fix a handle leak for error returns in ldb_try_load_dso
Coverity ID 464 (cherry picked from commit 496d44d2f21661c85bf07e8eb7cae6298fefd900) (This used to be commit f30bc6503de6c712101e04fe26c004eeffcd300e)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/ldb/common/ldb_modules.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/source3/lib/ldb/common/ldb_modules.c b/source3/lib/ldb/common/ldb_modules.c
index 68c4535e4d..d898f3df03 100644
--- a/source3/lib/ldb/common/ldb_modules.c
+++ b/source3/lib/ldb/common/ldb_modules.c
@@ -206,6 +206,7 @@ int ldb_try_load_dso(struct ldb_context *ldb, const char *name)
void *handle;
int (*init_fn) (void);
char *modulesdir;
+ int ret;
#ifdef HAVE_DLOPEN
if (getenv("LD_LDB_MODULE_PATH") != NULL) {
@@ -234,12 +235,17 @@ int ldb_try_load_dso(struct ldb_context *ldb, const char *name)
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;