mirror of
https://github.com/MidnightCommander/mc
synced 2025-03-10 10:01:36 +03:00
(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:
parent
61f997de26
commit
5f482396f6
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user