diff options
Diffstat (limited to 'src/nvim/channel.c')
| -rw-r--r-- | src/nvim/channel.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/nvim/channel.c b/src/nvim/channel.c index db0a2ff64c..9662f6205f 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -1,6 +1,7 @@ // This is an open source non-commercial project. Dear PVS-Studio, please check // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com +#include "nvim/api/private/converter.h" #include "nvim/api/private/helpers.h" #include "nvim/api/ui.h" #include "nvim/channel.h" @@ -8,6 +9,7 @@ #include "nvim/eval/encode.h" #include "nvim/event/socket.h" #include "nvim/fileio.h" +#include "nvim/lua/executor.h" #include "nvim/msgpack_rpc/channel.h" #include "nvim/msgpack_rpc/server.h" #include "nvim/os/shell.h" @@ -136,6 +138,8 @@ bool channel_close(uint64_t id, ChannelPart part, const char **error) *error = (const char *)e_invstream; return false; } + api_free_luaref(chan->stream.internal.cb); + chan->stream.internal.cb = LUA_NOREF; break; default: @@ -315,7 +319,7 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout, CallbackReader if (pty) { if (detach) { - EMSG2(_(e_invarg2), "terminal/pty job cannot be detached"); + semsg(_(e_invarg2), "terminal/pty job cannot be detached"); shell_free_argv(argv); if (env) { tv_dict_free(env); @@ -365,7 +369,7 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout, CallbackReader int status = process_spawn(proc, has_in, has_out, has_err); if (status) { - EMSG3(_(e_jobspawn), os_strerror(status), cmd); + semsg(_(e_jobspawn), os_strerror(status), cmd); xfree(cmd); if (proc->env) { tv_dict_free(proc->env); @@ -420,6 +424,7 @@ uint64_t channel_connect(bool tcp, const char *address, bool rpc, CallbackReader // Create a loopback channel. This avoids deadlock if nvim connects to // its own named pipe. channel = channel_alloc(kChannelStreamInternal); + channel->stream.internal.cb = LUA_NOREF; rpc_start(channel); goto end; } @@ -530,7 +535,11 @@ size_t channel_send(uint64_t id, char *data, size_t len, bool data_owned, const goto retfree; } - if (chan->streamtype == kChannelStreamInternal && chan->term) { + if (chan->streamtype == kChannelStreamInternal) { + if (!chan->term) { + *error = _("Can't send data to closed stream"); + goto retfree; + } terminal_receive(chan->term, data, len); written = len; goto retfree; @@ -667,7 +676,7 @@ void channel_reader_callbacks(Channel *chan, CallbackReader *reader) tv_dict_add_list(reader->self, reader->type, strlen(reader->type), data); } else { - EMSG3(_(e_streamkey), reader->type, chan->id); + semsg(_(e_streamkey), reader->type, chan->id); } } else { channel_callback_call(chan, reader); |