diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-04-02 23:15:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-02 23:15:43 +0200 |
commit | 6db3ba9df27619703947fee11493354ca3a06878 (patch) | |
tree | 59477fd71aa69d5405a4a0eb58d0f503d16552b0 | |
parent | dde89730b453fd2b84860e58bb8893c92417128b (diff) | |
parent | 42d2bbe7d0df0354972d2d6a2896a795c1eeb936 (diff) | |
download | rneovim-6db3ba9df27619703947fee11493354ca3a06878.tar.gz rneovim-6db3ba9df27619703947fee11493354ca3a06878.tar.bz2 rneovim-6db3ba9df27619703947fee11493354ca3a06878.zip |
Merge pull request #14027 from dylanarmstrong/fix/13955-empty-paste-in-term-segfault
fix: segfault when pasting in term with empty buffer
-rw-r--r-- | src/nvim/terminal.c | 3 | ||||
-rw-r--r-- | test/functional/terminal/buffer_spec.lua | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 913ef3baed..afad20f557 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -580,6 +580,9 @@ static bool is_filter_char(int c) void terminal_paste(long count, char_u **y_array, size_t y_size) { + if (y_size == 0) { + return; + } vterm_keyboard_start_paste(curbuf->terminal->vt); terminal_flush_output(curbuf->terminal); size_t buff_len = STRLEN(y_array[0]); diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 209537831f..c61bf108cb 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -258,6 +258,13 @@ describe(':terminal buffer', function() it('handles wqall', function() eq('Vim(wqall):E948: Job still running', exc_exec('wqall')) end) + + it('does not segfault when pasting empty buffer #13955', function() + feed_command('terminal') + feed('<c-\\><c-n>') + feed_command('put a') -- buffer a is empty + helpers.assert_alive() + end) end) describe('No heap-buffer-overflow when using', function() |