(handle_console_linux): fix resource leak.

Handle open failure properly.

Found by Coverity.

Coverity id #32608.

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andreas Mohr 2020-12-08 15:10:05 +00:00 committed by Andrew Borodin
parent 61f997de26
commit 5f482396f6

View File

@ -191,6 +191,8 @@ handle_console_linux (console_action_t action)
/* Bind the pipe 0 to the standard input */
do
{
gboolean ok;
if (dup2 (pipefd1[0], STDIN_FILENO) == -1)
break;
status = close (pipefd1[0]);
@ -201,9 +203,13 @@ handle_console_linux (console_action_t action)
status = close (pipefd2[1]);
/* Bind standard error to /dev/null */
status = open ("/dev/null", O_WRONLY);
if (dup2 (status, STDERR_FILENO) == -1)
if (status == -1)
break;
ok = dup2 (status, STDERR_FILENO) != -1;
status = close (status);
if (!ok)
break;
if (tty_name != NULL)
{
char *mc_conssaver;