summaryrefslogtreecommitdiff
path: root/source3/rpcclient
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-03-28 15:49:13 +0100
committerMichael Adam <obnox@samba.org>2008-03-28 16:34:51 +0100
commit9644b6cb50ec01c04a0d6ab17a8e39054fd8b0f8 (patch)
treed000e447b508b5a8c282957f5b7921e768da0884 /source3/rpcclient
parentcc2f5fd1b5aa7e7a7277557edfd4b94b0d10661d (diff)
downloadsamba-9644b6cb50ec01c04a0d6ab17a8e39054fd8b0f8.tar.gz
samba-9644b6cb50ec01c04a0d6ab17a8e39054fd8b0f8.tar.bz2
samba-9644b6cb50ec01c04a0d6ab17a8e39054fd8b0f8.zip
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)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r--source3/rpcclient/cmd_spoolss.c12
1 files changed, 8 insertions, 4 deletions
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 <printer> <string|binary|dword|multistring>"
" <value> <data>\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);