s3: Fix Coverity ID 242696 Dereference before null check
authorVolker Lendecke <vl@samba.org>
Wed, 9 May 2012 07:16:54 +0000 (09:16 +0200)
committerVolker Lendecke <vl@samba.org>
Thu, 10 May 2012 07:11:56 +0000 (09:11 +0200)
winreg_printer_openkey above already dereferences winreg_handle

source3/rpc_client/cli_winreg_spoolss.c

index cd2cf681b86a046f152dc862b6c66f8870825487..1d90d5e69e029efdf24268613ecf5d705a05326c 100644 (file)
@@ -1906,6 +1906,7 @@ WERROR winreg_set_printer_dataex(TALLOC_CTX *mem_ctx,
        struct winreg_String wvalue = { 0, };
        char *path;
        WERROR result = WERR_OK;
+       WERROR ignore;
        NTSTATUS status;
        TALLOC_CTX *tmp_ctx;
 
@@ -1955,15 +1956,11 @@ WERROR winreg_set_printer_dataex(TALLOC_CTX *mem_ctx,
        }
 
 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);