summaryrefslogtreecommitdiffstats
path: root/src/channel.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-02-03 21:32:46 +0100
committerBram Moolenaar <Bram@vim.org>2016-02-03 21:32:46 +0100
commitfcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383 (patch)
tree59135ca051bf4f7f2fb68792651e6421cafd5e5f /src/channel.c
parentf92591f7f9fc78d2aced99befe444cb423b26df8 (diff)
patch 7.4.1249v7.4.1249
Problem: Crash when the process a channel is connected to exits. Solution: Use the file descriptor properly. Add a test. (Damien) Also add a test for eval().
Diffstat (limited to 'src/channel.c')
-rw-r--r--src/channel.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/channel.c b/src/channel.c
index 2f7403a854..2e5965bc7b 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -698,10 +698,14 @@ channel_exe_cmd(int idx, char_u *cmd, typval_T *arg2, typval_T *arg3)
}
else
{
- typval_T *tv = eval_expr(arg, NULL);
+ typval_T *tv;
typval_T err_tv;
char_u *json;
+ /* Don't pollute the display with errors. */
+ ++emsg_skip;
+ tv = eval_expr(arg, NULL);
+ --emsg_skip;
if (is_eval)
{
if (tv == NULL)
@@ -714,7 +718,8 @@ channel_exe_cmd(int idx, char_u *cmd, typval_T *arg2, typval_T *arg3)
channel_send(idx, json, "eval");
vim_free(json);
}
- free_tv(tv);
+ if (tv != &err_tv)
+ free_tv(tv);
}
}
else if (p_verbose > 2)
@@ -1119,7 +1124,8 @@ channel_read_json_block(int ch_idx, int id, typval_T **rettv)
/* Wait for up to 2 seconds.
* TODO: use timeout set on the channel. */
- if (channel_wait(channels[ch_idx].ch_fd, 2000) == FAIL)
+ if (channels[ch_idx].ch_fd < 0
+ || channel_wait(channels[ch_idx].ch_fd, 2000) == FAIL)
break;
channel_read(ch_idx);
}