From f8afaa76f225e4e7a477a59fa0a4b8f040afb2b6 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 25 Jul 2011 17:48:08 +0200 Subject: s3-rpc_client: Close the hive handle before we open it again. --- source3/rpc_client/cli_winreg_spoolss.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/source3/rpc_client/cli_winreg_spoolss.c b/source3/rpc_client/cli_winreg_spoolss.c index d0c048c3cc..ebdd419a65 100644 --- a/source3/rpc_client/cli_winreg_spoolss.c +++ b/source3/rpc_client/cli_winreg_spoolss.c @@ -599,6 +599,7 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx, uint32_t i, count = ARRAY_SIZE(subkeys); uint32_t info2_mask = 0; WERROR result = WERR_OK; + WERROR ignore; TALLOC_CTX *tmp_ctx; tmp_ctx = talloc_stackframe(); @@ -634,6 +635,13 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx, goto done; } + if (is_valid_policy_hnd(&key_hnd)) { + dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore); + } + if (is_valid_policy_hnd(&hive_hnd)) { + dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore); + } + /* Create the main key */ result = winreg_printer_openkey(tmp_ctx, winreg_handle, @@ -902,15 +910,11 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx, secdesc); done: - if (winreg_handle != NULL) { - WERROR ignore; - - if (is_valid_policy_hnd(&key_hnd)) { - dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore); - } - if (is_valid_policy_hnd(&hive_hnd)) { - dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore); - } + if (is_valid_policy_hnd(&key_hnd)) { + dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore); + } + if (is_valid_policy_hnd(&hive_hnd)) { + dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore); } talloc_free(tmp_ctx); -- cgit