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().
diff --git a/src/channel.c b/src/channel.c
index 2f7403a..2e5965b 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -698,10 +698,14 @@
}
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_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 @@
/* 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);
}