Fix issues found by Coverity, closes #206.

This commit is contained in:
Ahsan Fayaz
2020-07-17 18:55:00 +01:00
parent f6c68cd6de
commit 510a0a6ae2
3 changed files with 36 additions and 20 deletions

View File

@@ -224,7 +224,8 @@ char *game_mode_resolve_wine_preloader(const char *exe, const pid_t pid)
goto fail;
error_cleanup:
game_mode_close_proc(proc_fd);
if (proc_fd != INVALID_PROCFD)
game_mode_close_proc(proc_fd);
free(wineprefix);
return wine_exe;

View File

@@ -132,11 +132,19 @@ static void daemonize(const char *name)
/* replace standard file descriptors by /dev/null */
int devnull_r = open("/dev/null", O_RDONLY);
int devnull_w = open("/dev/null", O_WRONLY);
dup2(devnull_r, STDIN_FILENO);
dup2(devnull_w, STDOUT_FILENO);
dup2(devnull_w, STDERR_FILENO);
close(devnull_r);
close(devnull_w);
if (devnull_r == -1 || devnull_w == -1)
{
LOG_ERROR("Failed to redirect standard input and output to /dev/null\n");
}
else
{
dup2(devnull_r, STDIN_FILENO);
dup2(devnull_w, STDOUT_FILENO);
dup2(devnull_w, STDERR_FILENO);
close(devnull_r);
close(devnull_w);
}
}
/**