mirror of
https://github.com/samba-team/samba.git
synced 2025-10-24 15:33:20 +03:00
r2627: use the new talloc capabilities in a bunch more places in the rpc
server code. This fixes a number of memory leaks I found when testing with valgrind and smbtorture, as the cascading effect of a talloc_free() ensures that anything derived from the top level object is destroyed on disconnect.
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
458f853288
commit
76d0b8206c
@@ -28,19 +28,12 @@
|
||||
struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection *dce_conn,
|
||||
uint8_t handle_type)
|
||||
{
|
||||
TALLOC_CTX *mem_ctx;
|
||||
struct dcesrv_handle *h;
|
||||
|
||||
mem_ctx = talloc_init("rpc handle type %d\n", handle_type);
|
||||
if (!mem_ctx) {
|
||||
return NULL;
|
||||
}
|
||||
h = talloc(mem_ctx, sizeof(*h));
|
||||
h = talloc_p(dce_conn, struct dcesrv_handle);
|
||||
if (!h) {
|
||||
talloc_destroy(mem_ctx);
|
||||
return NULL;
|
||||
}
|
||||
h->mem_ctx = mem_ctx;
|
||||
h->data = NULL;
|
||||
h->destroy = NULL;
|
||||
|
||||
@@ -62,7 +55,7 @@ void dcesrv_handle_destroy(struct dcesrv_connection *dce_conn,
|
||||
h->destroy(dce_conn, h);
|
||||
}
|
||||
DLIST_REMOVE(dce_conn->handles, h);
|
||||
talloc_destroy(h->mem_ctx);
|
||||
talloc_free(h);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user