diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-02-16 12:44:26 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-02-16 12:44:26 +0100 |
commit | 5cefd4098204b4677387511b586673649f2fab48 (patch) | |
tree | 38f2c816c39b9897c265b168d789e980e3a4cc61 /src | |
parent | 12dcf024e90ab511f04a08b20fe7eedbe92096d2 (diff) | |
download | vim-git-5cefd4098204b4677387511b586673649f2fab48.tar.gz |
patch 7.4.1329v7.4.1329
Problem: Crash when using channel that failed to open.
Solution: Check for NULL. Update messages. (Yukihiro Nakadaira)
Diffstat (limited to 'src')
-rw-r--r-- | src/channel.c | 4 | ||||
-rw-r--r-- | src/eval.c | 8 | ||||
-rw-r--r-- | src/testdir/test_channel.vim | 6 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 16 insertions, 4 deletions
diff --git a/src/channel.c b/src/channel.c index d5d7ffb49..003c93336 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 a90dd0b73..ff7f9a7bd 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; } @@ -22467,7 +22470,8 @@ copy_tv(typval_T *from, typval_T *to) case VAR_CHANNEL: #ifdef FEAT_CHANNEL to->vval.v_channel = from->vval.v_channel; - ++to->vval.v_channel->ch_refcount; + if (to->vval.v_channel != NULL) + ++to->vval.v_channel->ch_refcount; break; #endif case VAR_STRING: diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index e7448faf0..7cc3f146f 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -318,3 +318,9 @@ endfunc func Test_unlet_handle() call s:run_server('s:unlet_handle') endfunc + +func Test_open_fail() + silent! let ch = ch_open("noserver") + echo ch + let d = ch +endfunc diff --git a/src/version.c b/src/version.c index c880078a6..fc1c8824d 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1329, +/**/ 1328, /**/ 1327, |