comparison 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
comparison
equal deleted inserted replaced
7905:dfdf2ee817fa 7906:ea1fd8d750a6
696 if (p_verbose > 2) 696 if (p_verbose > 2)
697 EMSG("E904: third argument for eval must be a number"); 697 EMSG("E904: third argument for eval must be a number");
698 } 698 }
699 else 699 else
700 { 700 {
701 typval_T *tv = eval_expr(arg, NULL); 701 typval_T *tv;
702 typval_T err_tv; 702 typval_T err_tv;
703 char_u *json; 703 char_u *json;
704 704
705 /* Don't pollute the display with errors. */
706 ++emsg_skip;
707 tv = eval_expr(arg, NULL);
708 --emsg_skip;
705 if (is_eval) 709 if (is_eval)
706 { 710 {
707 if (tv == NULL) 711 if (tv == NULL)
708 { 712 {
709 err_tv.v_type = VAR_STRING; 713 err_tv.v_type = VAR_STRING;
712 } 716 }
713 json = json_encode_nr_expr(arg3->vval.v_number, tv); 717 json = json_encode_nr_expr(arg3->vval.v_number, tv);
714 channel_send(idx, json, "eval"); 718 channel_send(idx, json, "eval");
715 vim_free(json); 719 vim_free(json);
716 } 720 }
717 free_tv(tv); 721 if (tv != &err_tv)
722 free_tv(tv);
718 } 723 }
719 } 724 }
720 else if (p_verbose > 2) 725 else if (p_verbose > 2)
721 EMSG2("E905: received unknown command: %s", cmd); 726 EMSG2("E905: received unknown command: %s", cmd);
722 } 727 }
1117 if (channel_parse_messages()) 1122 if (channel_parse_messages())
1118 continue; 1123 continue;
1119 1124
1120 /* Wait for up to 2 seconds. 1125 /* Wait for up to 2 seconds.
1121 * TODO: use timeout set on the channel. */ 1126 * TODO: use timeout set on the channel. */
1122 if (channel_wait(channels[ch_idx].ch_fd, 2000) == FAIL) 1127 if (channels[ch_idx].ch_fd < 0
1128 || channel_wait(channels[ch_idx].ch_fd, 2000) == FAIL)
1123 break; 1129 break;
1124 channel_read(ch_idx); 1130 channel_read(ch_idx);
1125 } 1131 }
1126 } 1132 }
1127 return FAIL; 1133 return FAIL;