summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common/ldb.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2006-07-06 05:08:30 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:09:47 -0500
commit44e6f21393ea6f2531c6d1e789a0a01582bc6dca (patch)
tree3d34180ed1de88b3e0e8e63832fb138ba4e33b96 /source4/lib/ldb/common/ldb.c
parent927cbf74ae1c08876a717f739449177d03740f2e (diff)
downloadsamba-44e6f21393ea6f2531c6d1e789a0a01582bc6dca.tar.gz
samba-44e6f21393ea6f2531c6d1e789a0a01582bc6dca.tar.bz2
samba-44e6f21393ea6f2531c6d1e789a0a01582bc6dca.zip
r16825: Make ldb_sainity_check() set an error string. This makes it much
easier to chase down what modules or application code gets wrong. Ensure not to leave memory allocated on failure in ldb_search() Andrew Bartlett (This used to be commit 0828739951ed879640f8ed6e4700d8ca6b8221b8)
Diffstat (limited to 'source4/lib/ldb/common/ldb.c')
-rw-r--r--source4/lib/ldb/common/ldb.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 5228eeb6b3..c059646629 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -527,11 +527,8 @@ int ldb_search(struct ldb_context *ldb,
struct ldb_request *req;
int ret;
- *res = talloc_zero(ldb, struct ldb_result);
- if (! *res) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
+ *res = NULL;
+
req = talloc(ldb, struct ldb_request);
if (req == NULL) {
ldb_set_errstring(ldb, talloc_strdup(ldb, "Out of memory!"));
@@ -549,6 +546,12 @@ int ldb_search(struct ldb_context *ldb,
return LDB_ERR_OPERATIONS_ERROR;
}
+ *res = talloc_zero(ldb, struct ldb_result);
+ if (! *res) {
+ talloc_free(req);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
req->op.search.attrs = attrs;
req->controls = NULL;
req->async.context = res;
@@ -581,9 +584,11 @@ int ldb_add(struct ldb_context *ldb,
struct ldb_request *req;
int ret;
- ret = ldb_msg_sanity_check(message);
- if (ret != LDB_SUCCESS) return ret;
-
+ ret = ldb_msg_sanity_check(ldb, message);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+
req = talloc(ldb, struct ldb_request);
if (req == NULL) {
ldb_set_errstring(ldb, talloc_strdup(ldb, "Out of memory!"));
@@ -613,7 +618,7 @@ int ldb_modify(struct ldb_context *ldb,
struct ldb_request *req;
int ret;
- ret = ldb_msg_sanity_check(message);
+ ret = ldb_msg_sanity_check(ldb, message);
if (ret != LDB_SUCCESS) return ret;
req = talloc(ldb, struct ldb_request);