Rework memory handling in extended_dn_in
authorAndrew Bartlett <abartlet@samba.org>
Thu, 13 Nov 2008 04:04:47 +0000 (15:04 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 13 Nov 2008 04:04:47 +0000 (15:04 +1100)
source4/dsdb/samdb/ldb_modules/extended_dn_in.c

index 48360e4470a8fc01813c44996ec7071c79dd7d5f..928cf387f4fbd76566a2f821435a90b141e61bf6 100644 (file)
@@ -54,6 +54,8 @@ static int extended_final_callback(struct ldb_request *req, struct ldb_reply *ar
        if (ares->error != LDB_SUCCESS) {
                ret = ldb_module_done(ac->req, ares->controls,
                                      ares->response, ares->error);
+               talloc_steal(ac->req, ares);
+               talloc_free(ac);
        } else {
                switch (ares->type) {
                case LDB_REPLY_ENTRY:
@@ -68,11 +70,11 @@ static int extended_final_callback(struct ldb_request *req, struct ldb_reply *ar
                        
                        ret = ldb_module_done(ac->req, ares->controls,
                                              ares->response, ares->error);
+                       talloc_steal(ac->req, ares);
+                       talloc_free(ac);
                        break;
                }
        }
-       talloc_steal(ac->req, ares);
-       talloc_free(ac);
        return ret;
 }
 
@@ -81,7 +83,6 @@ static int extended_base_callback(struct ldb_request *req, struct ldb_reply *are
        struct extended_search_context *ac;
        struct ldb_request *down_req;
        struct ldb_message_element *el;
-       struct ldb_module *module;
        int ret;
        size_t i;
        size_t wkn_len = 0;
@@ -102,7 +103,7 @@ static int extended_base_callback(struct ldb_request *req, struct ldb_reply *are
        switch (ares->type) {
        case LDB_REPLY_ENTRY:
                if (!ac->wellknown_object) {
-                       ac->basedn = ares->message->dn;
+                       ac->basedn = talloc_steal(ac, ares->message->dn);
                        break;
                }