svn commit: samba r22749 - in branches/SAMBA_4_0/source/libcli/nbt: .

metze at samba.org metze at samba.org
Mon May 7 15:27:51 GMT 2007


Author: metze
Date: 2007-05-07 15:27:50 +0000 (Mon, 07 May 2007)
New Revision: 22749

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22749

Log:
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
Modified:
   branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c


Changeset:
Modified: branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c	2007-05-07 15:19:53 UTC (rev 22748)
+++ branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c	2007-05-07 15:27:50 UTC (rev 22749)
@@ -45,6 +45,7 @@
 		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 @@
 	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 @@
 	}
 	if (req->async.fn) {
 		req->async.fn(req);
+	} else if (req->is_reply) {
+		talloc_free(req);
 	}
 }
 
@@ -462,9 +467,7 @@
 		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;



More information about the samba-cvs mailing list