Steps to reproduce: :" 1 :echo ch_open("noserver") :" 2 :let c = ch_open("noserver") :let d = c
There is no NULL check for fail channel. And two typos in message. diff --git a/src/channel.c b/src/channel.c index d5d7ffb..003c933 100644 --- a/src/channel.c +++ b/src/channel.c @@ -634,7 +634,7 @@ channel_open(char *hostname, int port_in, int waittime, void (*close_cb)(void)) { /* Get here when the server can't be found. */ ch_error(NULL, "Cannot connect to port after retry\n"); - PERROR(_("E899: Cannot connect to port after retry2")); + PERROR(_("E899: Cannot connect to port after retry")); sock_close(sd); channel_free(channel); return NULL; @@ -1220,7 +1220,7 @@ channel_status(channel_T *channel) void channel_close(channel_T *channel) { - ch_log(channel, "Closing channel"); + ch_log(channel, "Closing channel\n"); #ifdef FEAT_GUI channel_gui_unregister(channel); diff --git a/src/eval.c b/src/eval.c index a90dd0b..e071085 100644 --- a/src/eval.c +++ b/src/eval.c @@ -21828,7 +21828,10 @@ get_tv_string_buf_chk(typval_T *varp, char_u *buf) channel_T *channel = varp->vval.v_channel; char *status = channel_status(channel); - vim_snprintf((char *)buf, NUMBUFLEN, + if (channel == NULL) + vim_snprintf((char *)buf, NUMBUFLEN, "channel %s", status); + else + vim_snprintf((char *)buf, NUMBUFLEN, "channel %d %s", channel->ch_id, status); return buf; } @@ -22466,8 +22469,13 @@ copy_tv(typval_T *from, typval_T *to) #endif case VAR_CHANNEL: #ifdef FEAT_CHANNEL - to->vval.v_channel = from->vval.v_channel; - ++to->vval.v_channel->ch_refcount; + if (from->vval.v_channel == NULL) + to->vval.v_channel = NULL; + else + { + to->vval.v_channel = from->vval.v_channel; + ++to->vval.v_channel->ch_refcount; + } break; #endif case VAR_STRING: -- Yukihiro Nakadaira - yukihiro.nakada...@gmail.com -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.