mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
fix(channel): throw error if sending to internal channel w/o terminal
Prevent SIGABRT when sending to a channel created by nvim_open_term() after the associated terminal has been deleted.
This commit is contained in:
parent
14def4d227
commit
3b89fee246
@ -535,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;
|
||||
|
@ -281,4 +281,14 @@ describe('channels', function()
|
||||
-- works correctly with no output
|
||||
eq({"notification", "exit", {id, 1, {''}}}, next_msg())
|
||||
end)
|
||||
|
||||
it('should throw error when writing to a channel associated with a deleted terminal', function()
|
||||
source([[
|
||||
let id = nvim_open_term(0, {})
|
||||
bdelete!
|
||||
let v:errmsg = ''
|
||||
silent! call chansend(id, 'test')
|
||||
]])
|
||||
eq("Can't send data to closed stream", eval('v:errmsg'))
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user