summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-05-07 15:27:50 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:52:09 -0500
commit7fe9a3255ae84ed531d0a3d0a8cbf0812559fc5e (patch)
treee334a9f64f5b408defbc996f3210cd9d8590ab15
parent68b531e81784d218b598e4ec403443bbc039ca77 (diff)
downloadsamba-7fe9a3255ae84ed531d0a3d0a8cbf0812559fc5e.tar.gz
samba-7fe9a3255ae84ed531d0a3d0a8cbf0812559fc5e.tar.bz2
samba-7fe9a3255ae84ed531d0a3d0a8cbf0812559fc5e.zip
r22749: fix memory leak of nbt_name_request structure which are used to send replies
and never have an async callback that could free it. we only had the memory leak in the error path the standard path was ok. metze (This used to be commit d2a2fe662db5b773f4bd54498d6b31b773633903)
-rw-r--r--source4/libcli/nbt/nbtsocket.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/source4/libcli/nbt/nbtsocket.c b/source4/libcli/nbt/nbtsocket.c
index c1e30fc245..0931de63c8 100644
--- a/source4/libcli/nbt/nbtsocket.c
+++ b/source4/libcli/nbt/nbtsocket.c
@@ -45,6 +45,7 @@ static int nbt_name_request_destructor(struct nbt_name_request *req)
req->name_trn_id = 0;
}
if (req->te) {
+ talloc_free(req->te);
req->te = NULL;
}
if (req->nbtsock->send_queue == NULL) {
@@ -102,6 +103,8 @@ failed:
talloc_free(tmp_ctx);
if (req->async.fn) {
req->async.fn(req);
+ } else if (req->is_reply) {
+ talloc_free(req);
}
return;
}
@@ -140,6 +143,8 @@ static void nbt_name_socket_timeout(struct event_context *ev, struct timed_event
}
if (req->async.fn) {
req->async.fn(req);
+ } else if (req->is_reply) {
+ talloc_free(req);
}
}
@@ -462,9 +467,7 @@ NTSTATUS nbt_name_request_recv(struct nbt_name_request *req)
if (event_loop_once(req->nbtsock->event_ctx) != 0) {
req->state = NBT_REQUEST_ERROR;
req->status = NT_STATUS_UNEXPECTED_NETWORK_ERROR;
- if (req->async.fn) {
- req->async.fn(req);
- }
+ break;
}
}
return req->status;