Mercurial > vim
diff src/channel.c @ 7906:ea1fd8d750a6 v7.4.1249
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Feb 3 21:32:46 2016 +0100
patch 7.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().
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 03 Feb 2016 21:45:04 +0100 |
parents | 93c61501c2cf |
children | 54602dcac207 |
line wrap: on
line diff
--- a/src/channel.c +++ b/src/channel.c @@ -698,10 +698,14 @@ channel_exe_cmd(int idx, char_u *cmd, ty } 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, ty 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 /* 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); }