mirror of
https://github.com/samba-team/samba.git
synced 2025-02-28 01:58:17 +03:00
dsdb: Replace talloc_steal() with a shallow copy and reference in dsdb_paged_results
We should not be stealing caller memory like this, and while a talloc_reference() is not much better, this combined with a shallow copy should be a little better in terms of polite memory management. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15442 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
parent
1b68bd977a
commit
3b51091c20
@ -681,6 +681,7 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req)
|
||||
struct ldb_control *ext_ctrl;
|
||||
struct ldb_control **controls;
|
||||
static const char * const attrs[1] = { NULL };
|
||||
void *ref = NULL;
|
||||
|
||||
if (paged_ctrl->size == 0) {
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
@ -739,7 +740,25 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ac->store->expr = talloc_steal(ac->store, req->op.search.tree);
|
||||
/*
|
||||
* LDB does not have a function to take a full copy of
|
||||
* this, but at least take a shallow copy
|
||||
*/
|
||||
ac->store->expr = ldb_parse_tree_copy_shallow(ac->store,
|
||||
req->op.search.tree);
|
||||
|
||||
if (ac->store->expr == NULL) {
|
||||
return ldb_operr(ldb);
|
||||
}
|
||||
|
||||
/*
|
||||
* As the above is only a shallow copy, take a
|
||||
* reference to ensure the values are kept around
|
||||
*/
|
||||
ref = talloc_reference(ac->store, req->op.search.tree);
|
||||
if (ref == NULL) {
|
||||
return ldb_module_oom(module);
|
||||
}
|
||||
ac->store->expr_str = ldb_filter_from_tree(ac->store,
|
||||
req->op.search.tree);
|
||||
if (ac->store->expr_str == NULL) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user