Fix Uninitialized variables pointed out by Coverity
authorTakuma Hoshiai <takuma.hoshiai@gmail.com>
Mon, 9 Jan 2023 18:08:13 +0000 (03:08 +0900)
committerTakuma Hoshiai <takuma.hoshiai@gmail.com>
Mon, 9 Jan 2023 18:08:13 +0000 (03:08 +0900)
Fix Uninitialized variables pointed out by Coverity.

src/watchdog/wd_ping.c

index 89bbe0b3f3f0b2b2a2783e6d6081257c873a1c94..9be1ddb3a2e610fa1fdf0fa88d94488d55732f1a 100644 (file)
@@ -231,10 +231,13 @@ wd_trusted_server_command(char *hostname)
                dup2(fd, 2);
                close(fd);
 
-               if (strlen(exec_cmd->data) != 0)
+               if (strlen(exec_cmd->data) == 0)
                {
-                       status = system(exec_cmd->data);
+                       pfree(exec_cmd->data);
+                       exit(EXIT_FAILURE);
                }
+
+               status = system(exec_cmd->data);
                pfree(exec_cmd->data);
 
                if (WIFEXITED(status) == 0 || WEXITSTATUS(status) != 0)