r13360: Fix crash bug when 0 results are returned on the internal base search
authorSimo Sorce <idra@samba.org>
Mon, 6 Feb 2006 00:39:05 +0000 (00:39 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:51:50 +0000 (13:51 -0500)
source/lib/ldb/modules/asq.c

index 7e6bbdf29ea899e17f62f6f7c9dec7cc1cfa84b0..905bab480a363cb00c3d26f3ea6bc9df7076a4f0 100644 (file)
@@ -126,14 +126,22 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req)
 
        ret = ldb_request(module->ldb, base_req);
 
-       if (ret != LDB_SUCCESS)
+       if (ret != LDB_SUCCESS) {
+               talloc_free(base_req);
                return ret;
+       }
 
+       if (base_req->op.search.res->count == 0) {
+               talloc_free(base_req);
+               return build_response(res, ASQ_CTRL_SUCCESS);
+       }
+       
        /* look up the DNs */
        el = ldb_msg_find_element(base_req->op.search.res->msgs[0],
                                  asq_ctrl->source_attribute);
        /* no values found */
        if (el == NULL) {
+               talloc_free(base_req);
                return build_response(res, ASQ_CTRL_SUCCESS);
        }
 
@@ -181,6 +189,8 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req)
                talloc_free(exp_req);
        }
 
+       talloc_free(base_req);
+
        return build_response(res, ASQ_CTRL_SUCCESS);
 }