summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-03-28 23:27:47 +0100
committerStefan Metzmacher <metze@samba.org>2009-04-01 16:41:14 +0200
commit794525f3427e5f01656f205504d478318d9620a4 (patch)
treeffd3df3d9345a85129a28e8213185d9788fa98dc
parentffdc2a3fe8437582ded1c4a3b09a54201519889b (diff)
downloadsamba-794525f3427e5f01656f205504d478318d9620a4.tar.gz
samba-794525f3427e5f01656f205504d478318d9620a4.tar.bz2
samba-794525f3427e5f01656f205504d478318d9620a4.zip
libcli/cldap: fix memory/resource leak
We need to remove the message id, when a search request is finished metze
-rw-r--r--libcli/cldap/cldap.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libcli/cldap/cldap.c b/libcli/cldap/cldap.c
index 561ae8037c..d3fb0bb1e9 100644
--- a/libcli/cldap/cldap.c
+++ b/libcli/cldap/cldap.c
@@ -510,6 +510,10 @@ static void cldap_reply_state_destroy(struct tevent_req *req)
static int cldap_search_state_destructor(struct cldap_search_state *s)
{
if (s->caller.cldap) {
+ if (s->message_id != -1) {
+ idr_remove(s->caller.cldap->searches.idr, s->message_id);
+ s->message_id = -1;
+ }
DLIST_REMOVE(s->caller.cldap->searches.list, s);
cldap_recvfrom_stop(s->caller.cldap);
ZERO_STRUCT(s->caller);
@@ -542,8 +546,12 @@ struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
if (!req) {
return NULL;
}
+ ZERO_STRUCTP(state);
state->req = req;
state->caller.cldap = cldap;
+ state->message_id = -1;
+
+ talloc_set_destructor(state, cldap_search_state_destructor);
if (io->in.dest_address) {
if (cldap->connected) {
@@ -634,7 +642,6 @@ struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
tevent_req_set_callback(subreq, cldap_search_state_queue_done, req);
DLIST_ADD_END(cldap->searches.list, state, struct cldap_search_state *);
- talloc_set_destructor(state, cldap_search_state_destructor);
return req;