s3-rpc_client: Close hive if opening of the key fails.
authorAndreas Schneider <asn@samba.org>
Mon, 25 Jul 2011 20:31:08 +0000 (22:31 +0200)
committerAndreas Schneider <asn@samba.org>
Wed, 27 Jul 2011 06:49:58 +0000 (08:49 +0200)
source3/rpc_client/cli_winreg_spoolss.c

index 9b7c72421cedb9470724a40662a3e51328394d31..d0c048c3cc85f4bbaf201fa2b45e61a7b04e5e65 100644 (file)
@@ -298,9 +298,19 @@ static WERROR winreg_printer_openkey(TALLOC_CTX *mem_ctx,
                                               &result);
        }
        if (!NT_STATUS_IS_OK(status)) {
-               return ntstatus_to_werror(status);
+               result = ntstatus_to_werror(status);
        }
        if (!W_ERROR_IS_OK(result)) {
+               WERROR ignore;
+
+               if (is_valid_policy_hnd(hive_handle)) {
+                       dcerpc_winreg_CloseKey(binding_handle,
+                                              mem_ctx,
+                                              hive_handle,
+                                              &ignore);
+               }
+               ZERO_STRUCTP(hive_handle);
+
                return result;
        }