From 27620c85e7d55e6e522b39c7aea8f83c2b5eb9b1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 1 Jul 2009 15:13:49 +1000 Subject: use a talloc_reparent in a very ugly way this works around some terrible use of talloc in the libnet code --- source4/libnet/libnet_rpc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source4/libnet') diff --git a/source4/libnet/libnet_rpc.c b/source4/libnet/libnet_rpc.c index 66e12d0da1..4524448928 100644 --- a/source4/libnet/libnet_rpc.c +++ b/source4/libnet/libnet_rpc.c @@ -400,8 +400,17 @@ static NTSTATUS libnet_RpcConnectDC_recv(struct composite_context *c, status = composite_wait(c); if (NT_STATUS_IS_OK(status)) { - /* move connected rpc pipe between memory contexts */ - r->out.dcerpc_pipe = talloc_steal(mem_ctx, s->r.out.dcerpc_pipe); + /* move connected rpc pipe between memory contexts + + The use of talloc_reparent(talloc_parent(), ...) is + bizarre, but it is needed because of the absolutely + atrocious use of talloc in this code. We need to + force the original parent to change, but finding + the original parent is well nigh impossible at this + point in the code (yes, I tried). + */ + r->out.dcerpc_pipe = talloc_reparent(talloc_parent(s->r.out.dcerpc_pipe), + mem_ctx, s->r.out.dcerpc_pipe); /* reference created pipe structure to long-term libnet_context so that it can be used by other api functions even after short-term -- cgit