s3: Fix Coverity ID 242691 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:57 +0000 (09:11 +0200)
winreg_printer_openkey above already dereferences winreg_handle

source3/rpc_client/cli_winreg_spoolss.c

index 2686c60e62f629418ad4054742249e2d424c6d06..a0bbd91c7d0730678adbd5053bee2f99b76fab9f 100644 (file)
@@ -1619,6 +1619,7 @@ WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx,
        TALLOC_CTX *tmp_ctx;
        NTSTATUS status;
        WERROR result;
+       WERROR ignore;
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
@@ -1660,7 +1661,6 @@ WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx,
        }
        if (!W_ERROR_IS_OK(result)) {
                if (W_ERROR_EQUAL(result, WERR_BADFILE)) {
-                       WERROR ignore;
 
                        if (is_valid_policy_hnd(&key_hnd)) {
                                dcerpc_winreg_CloseKey(winreg_handle,
@@ -1758,15 +1758,11 @@ create_default:
 
        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);