r25856: If the search fails, it is not valid to steal 'res'.
authorAndrew Bartlett <abartlet@samba.org>
Tue, 6 Nov 2007 02:46:57 +0000 (03:46 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2007 04:44:29 +0000 (05:44 +0100)
Andrew Bartlett
(This used to be commit f4d733c3d00c90ac2e02fcc202240ae7c290463e)

source4/lib/ldb/common/ldb_modules.c

index 87e5b2eeb35b1201f7cd22ec2d72d659a8275496..2ffd49786ba914a0697189cf94aba35fecca1943 100644 (file)
@@ -322,15 +322,16 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
                }
 
                ret = ldb_search(ldb, mods_dn, LDB_SCOPE_BASE, "", attrs, &res);
+               
+               if (ret != LDB_SUCCESS) {
+                       ldb_debug(ldb, LDB_DEBUG_FATAL, "ldb error (%s) occurred searching for modules, bailing out\n", ldb_errstring(ldb));
+                       talloc_free(mem_ctx);
+                       return -1;
+               }
                talloc_steal(mods_dn, res);
-               if (ret == LDB_SUCCESS && (res->count == 0 || res->msgs[0]->num_elements == 0)) {
+               if (res->count == 0 || res->msgs[0]->num_elements == 0) {
                        ldb_debug(ldb, LDB_DEBUG_TRACE, "no modules required by the db");
                } else {
-                       if (ret != LDB_SUCCESS) {
-                               ldb_debug(ldb, LDB_DEBUG_FATAL, "ldb error (%s) occurred searching for modules, bailing out\n", ldb_errstring(ldb));
-                               talloc_free(mem_ctx);
-                               return -1;
-                       }
                        if (res->count > 1) {
                                ldb_debug(ldb, LDB_DEBUG_FATAL, "Too many records found (%d), bailing out\n", res->count);
                                talloc_free(mem_ctx);