From 76ecf81428c161a98a5621b55a64cb8515f80585 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Jul 2005 01:10:09 +0000 Subject: r8273: fixed some memory leaks in smbscript. This required converting file_load() to use talloc, which impacted quite a few bits of code, including our smb.conf processing. took the opportunity to remove the gloabls in params.c while doing this (This used to be commit b220756cb4f1d201ba3e771ca67e4bfae5eae748) --- source4/scripting/ejs/smbcalls_rpc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'source4/scripting/ejs/smbcalls_rpc.c') diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c index 12b0d95e8e..8a5389fbab 100644 --- a/source4/scripting/ejs/smbcalls_rpc.c +++ b/source4/scripting/ejs/smbcalls_rpc.c @@ -105,6 +105,7 @@ done: void *ptr; struct rpc_request *req; int callnum; + struct ejs_rpc *ejs; if (argc != 2 || argv[0]->type != MPR_TYPE_OBJECT || @@ -132,15 +133,24 @@ done: } callnum = call - iface->calls; + ejs = talloc(mprMemCtx(), struct ejs_rpc); + if (ejs == NULL) { + status = NT_STATUS_NO_MEMORY; + goto done; + } + + ejs->eid = eid; + ejs->callname = callname; + /* allocate the C structure */ - ptr = talloc_zero_size(mprMemCtx(), call->struct_size); + ptr = talloc_zero_size(ejs, call->struct_size); if (ptr == NULL) { status = NT_STATUS_NO_MEMORY; goto done; } /* convert the mpr object into a C structure */ - status = ejs_pull_rpc(eid, callname, io, ptr, ejs_pull); + status = ejs_pull(ejs, io, ptr); if (!NT_STATUS_IS_OK(status)) { goto done; } @@ -154,7 +164,6 @@ done: req = dcerpc_ndr_request_send(p, NULL, iface, callnum, ptr, ptr); if (req == NULL) { status = NT_STATUS_NO_MEMORY; - talloc_free(ptr); goto done; } status = dcerpc_ndr_request_recv(req); @@ -164,10 +173,10 @@ done: ndr_print_function_debug(call->ndr_print, call->name, NDR_OUT, ptr); } - status = ejs_push_rpc(eid, callname, io, ptr, ejs_push); + status = ejs_push(ejs, io, ptr); - talloc_free(ptr); done: + talloc_free(ejs); ejsSetReturnValue(eid, mprNTSTATUS(status)); if (NT_STATUS_EQUAL(status, NT_STATUS_INTERNAL_ERROR)) { return -1; -- cgit