Mercurial > vim
comparison src/os_unix.c @ 11894:75a85e99f53e v8.0.0827
patch 8.0.0827: Coverity: could leak pty file descriptor
commit https://github.com/vim/vim/commit/979e8c534684737920c1891bf9c4af9e1fdb8c3b
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 1 15:08:07 2017 +0200
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 01 Aug 2017 15:15:04 +0200 |
parents | 0cfe4a07c2ad |
children | 3c1b59938042 |
comparison
equal
deleted
inserted
replaced
11893:af79d760d8a1 | 11894:75a85e99f53e |
---|---|
4148 set_child_environment(Rows, Columns, "dumb"); | 4148 set_child_environment(Rows, Columns, "dumb"); |
4149 } | 4149 } |
4150 #endif | 4150 #endif |
4151 | 4151 |
4152 #if defined(FEAT_GUI) || defined(FEAT_JOB_CHANNEL) | 4152 #if defined(FEAT_GUI) || defined(FEAT_JOB_CHANNEL) |
4153 /* | |
4154 * Open a PTY, with FD for the master and slave side. | |
4155 * When failing "pty_master_fd" and "pty_slave_fd" are -1. | |
4156 * When successful both file descriptors are stored. | |
4157 */ | |
4153 static void | 4158 static void |
4154 open_pty(int *pty_master_fd, int *pty_slave_fd) | 4159 open_pty(int *pty_master_fd, int *pty_slave_fd) |
4155 { | 4160 { |
4156 char *tty_name; | 4161 char *tty_name; |
4157 | 4162 |
5377 use_file_for_out || use_null_for_out | 5382 use_file_for_out || use_null_for_out |
5378 ? INVALID_FD : fd_out[0] < 0 ? pty_master_fd : fd_out[0], | 5383 ? INVALID_FD : fd_out[0] < 0 ? pty_master_fd : fd_out[0], |
5379 use_out_for_err || use_file_for_err || use_null_for_err | 5384 use_out_for_err || use_file_for_err || use_null_for_err |
5380 ? INVALID_FD : fd_err[0] < 0 ? pty_master_fd : fd_err[0]); | 5385 ? INVALID_FD : fd_err[0] < 0 ? pty_master_fd : fd_err[0]); |
5381 channel_set_job(channel, job, options); | 5386 channel_set_job(channel, job, options); |
5387 } | |
5388 else | |
5389 { | |
5390 if (fd_in[1] >= 0) | |
5391 close(fd_in[1]); | |
5392 if (fd_out[0] >= 0) | |
5393 close(fd_out[0]); | |
5394 if (fd_err[0] >= 0) | |
5395 close(fd_err[0]); | |
5396 if (pty_master_fd >= 0) | |
5397 close(pty_master_fd); | |
5382 } | 5398 } |
5383 | 5399 |
5384 /* success! */ | 5400 /* success! */ |
5385 return; | 5401 return; |
5386 | 5402 |