s3: Fix Coverity ID 242694 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 1cf034e9f244b551409ac963e3c03307bd09fb84..c3c853d23f459b02d6addda91b96f16ca20ebabd 100644 (file)
@@ -2452,6 +2452,7 @@ WERROR winreg_printer_update_changeid(TALLOC_CTX *mem_ctx,
        char *path;
        NTSTATUS status;
        WERROR result;
+       WERROR ignore;
        TALLOC_CTX *tmp_ctx;
 
        tmp_ctx = talloc_stackframe();
@@ -2497,15 +2498,11 @@ WERROR winreg_printer_update_changeid(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);