From 9644b6cb50ec01c04a0d6ab17a8e39054fd8b0f8 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 28 Mar 2008 15:49:13 +0100 Subject: Add a talloc context parameter to current_timestring() to fix memleaks. current_timestring used to return a string talloced to talloc_tos(). When called by DEBUG from a TALLOC_FREE, this produced messages "no talloc stackframe around, leaking memory". For example when used from net conf. This also adds a temporary talloc context to alloc_sub_basic(). For this purpose, the exit strategy is slightly altered: a common exit point is used for success and failure. Michael (This used to be commit 16b5800d4e3a8b88bac67b2550d14e0aaaa302a9) --- source3/rpcclient/cmd_spoolss.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 5e0f694cf9..7530ab1911 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -1966,13 +1966,15 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli, PRINTER_INFO_CTR ctr; PRINTER_INFO_0 info; REGISTRY_VALUE value; + TALLOC_CTX *tmp_ctx = talloc_stackframe(); /* parse the command arguements */ if (argc < 5) { printf ("Usage: %s " " \n", argv[0]); - return WERR_INVALID_PARAM; + result = WERR_INVALID_PARAM; + goto done; } slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); @@ -2000,7 +2002,8 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli, if (value.type == REG_NONE) { printf("Unknown data type: %s\n", argv[2]); - return WERR_INVALID_PARAM; + result = WERR_INVALID_PARAM; + goto done; } /* get a printer handle */ @@ -2019,7 +2022,7 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli, if (!W_ERROR_IS_OK(result)) goto done; - printf("%s\n", current_timestring(True)); + printf("%s\n", current_timestring(tmp_ctx, True)); printf("\tchange_id (before set)\t:[0x%x]\n", info.change_id); /* Set the printer data */ @@ -2105,11 +2108,12 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli, if (!W_ERROR_IS_OK(result)) goto done; - printf("%s\n", current_timestring(True)); + printf("%s\n", current_timestring(tmp_ctx, True)); printf("\tchange_id (after set)\t:[0x%x]\n", info.change_id); done: /* cleanup */ + TALLOC_FREE(tmp_ctx); if (opened_hnd) rpccli_spoolss_close_printer(cli, mem_ctx, &pol); -- cgit