summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/rpc_client/cli_winreg_spoolss.c22
1 files 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);