s3: Fix Coverity ID 242705 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 64495f413517660f4fc49143a0a8da82dd0a9924..27bcb59099fa772808f1905ad628d8f1aba61a7b 100644 (file)
@@ -3056,6 +3056,7 @@ WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
        uint32_t num_builtin = ARRAY_SIZE(builtin_forms1);
        uint32_t i;
        WERROR result;
+       WERROR ignore;
        NTSTATUS status;
        TALLOC_CTX *tmp_ctx;
 
@@ -3158,15 +3159,11 @@ WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
 
        result = WERR_OK;
 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);