forked from aniani/vim
patch 8.0.0827: Coverity: could leak pty file descriptor
Problem: Coverity: could leak pty file descriptor, theoretically. Solution: If channel is NULL, free the file descriptors.
This commit is contained in:
@@ -4150,6 +4150,11 @@ set_default_child_environment(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(FEAT_GUI) || defined(FEAT_JOB_CHANNEL)
|
#if defined(FEAT_GUI) || defined(FEAT_JOB_CHANNEL)
|
||||||
|
/*
|
||||||
|
* Open a PTY, with FD for the master and slave side.
|
||||||
|
* When failing "pty_master_fd" and "pty_slave_fd" are -1.
|
||||||
|
* When successful both file descriptors are stored.
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
open_pty(int *pty_master_fd, int *pty_slave_fd)
|
open_pty(int *pty_master_fd, int *pty_slave_fd)
|
||||||
{
|
{
|
||||||
@@ -5380,6 +5385,17 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
|
|||||||
? INVALID_FD : fd_err[0] < 0 ? pty_master_fd : fd_err[0]);
|
? INVALID_FD : fd_err[0] < 0 ? pty_master_fd : fd_err[0]);
|
||||||
channel_set_job(channel, job, options);
|
channel_set_job(channel, job, options);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (fd_in[1] >= 0)
|
||||||
|
close(fd_in[1]);
|
||||||
|
if (fd_out[0] >= 0)
|
||||||
|
close(fd_out[0]);
|
||||||
|
if (fd_err[0] >= 0)
|
||||||
|
close(fd_err[0]);
|
||||||
|
if (pty_master_fd >= 0)
|
||||||
|
close(pty_master_fd);
|
||||||
|
}
|
||||||
|
|
||||||
/* success! */
|
/* success! */
|
||||||
return;
|
return;
|
||||||
|
@@ -769,6 +769,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
827,
|
||||||
/**/
|
/**/
|
||||||
826,
|
826,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user