summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-08-01 15:08:07 +0200
committerBram Moolenaar <Bram@vim.org>2017-08-01 15:08:07 +0200
commit979e8c534684737920c1891bf9c4af9e1fdb8c3b (patch)
treec97a7635bc3017aeec0c59a177f01067458b2cae
parent662d93866636995c0564d974e554f96e76fb2dd9 (diff)
patch 8.0.0827: Coverity: could leak pty file descriptorv8.0.0827
Problem: Coverity: could leak pty file descriptor, theoretically. Solution: If channel is NULL, free the file descriptors.
-rw-r--r--src/os_unix.c16
-rw-r--r--src/version.c2
2 files changed, 18 insertions, 0 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 5e744b6224..ff7661833f 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -4150,6 +4150,11 @@ set_default_child_environment(void)
#endif
#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
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]);
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! */
return;
diff --git a/src/version.c b/src/version.c
index 014dab6168..732e8a5269 100644
--- a/src/version.c
+++ b/src/version.c
@@ -770,6 +770,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 827,
+/**/
826,
/**/
825,