diff options
author | Christian Clason <c.clason@uni-graz.at> | 2022-01-28 09:30:52 +0100 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-01-28 19:03:37 +0800 |
commit | e691ef338c04893f3766fe9ba4e368cf8d5d5ad0 (patch) | |
tree | 91eecf5943a7584f124c2248ffe779b44111b0c4 /src | |
parent | 530c65b17ade3f5db70af5746f4eed945efdfcfa (diff) | |
download | rneovim-e691ef338c04893f3766fe9ba4e368cf8d5d5ad0.tar.gz rneovim-e691ef338c04893f3766fe9ba4e368cf8d5d5ad0.tar.bz2 rneovim-e691ef338c04893f3766fe9ba4e368cf8d5d5ad0.zip |
vim-patch:8.2.4233: crash when recording and using Select mode
Problem: Crash when recording and using Select mode.
Solution: When deleting the last recorded character check there is something
to delete.
https://github.com/vim/vim/commit/a4bc2dd7cccf5a4a9f78b58b6f35a45d17164323
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/getchar.c | 6 | ||||
-rw-r--r-- | src/nvim/testdir/test_registers.vim | 10 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 95720c498a..9c8872d2be 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -288,8 +288,12 @@ static void add_buff(buffheader_T *const buf, const char *const s, ptrdiff_t sle /// Only works when it was just added. static void delete_buff_tail(buffheader_T *buf, int slen) { - int len = (int)STRLEN(buf->bh_curr->b_str); + int len; + if (buf->bh_curr == NULL || buf->bh_curr->b_str == NULL) { + return; // nothing to delete + } + len = (int)STRLEN(buf->bh_curr->b_str); if (len >= slen) { buf->bh_curr->b_str[len - slen] = NUL; buf->bh_space += (size_t)slen; diff --git a/src/nvim/testdir/test_registers.vim b/src/nvim/testdir/test_registers.vim index f16793a08c..43af229739 100644 --- a/src/nvim/testdir/test_registers.vim +++ b/src/nvim/testdir/test_registers.vim @@ -511,4 +511,14 @@ func Test_insert_small_delete() bwipe! endfunc +func Test_record_in_select_mode() + new + call setline(1, 'text') + sil norm q00 + sil norm q + call assert_equal('0ext', getline(1)) + bwipe! +endfunc + + " vim: shiftwidth=2 sts=2 expandtab |