Skip to content

Commit

Permalink
patch 8.2.4233: crash when recording and using Select mode
Browse files Browse the repository at this point in the history
Problem:    Crash when recording and using Select mode.
Solution:   When deleting the last recorded character check there is something
            to delete.
  • Loading branch information
brammool committed Jan 27, 2022
1 parent 98cd303 commit a4bc2dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/getchar.c
Expand Up @@ -252,8 +252,11 @@ add_buff(
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;
Expand Down
9 changes: 9 additions & 0 deletions src/testdir/test_registers.vim
Expand Up @@ -739,6 +739,15 @@ func Test_record_in_insert_mode()
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

" Make sure that y_append is correctly reset
" and the previous register is working as expected
func Test_register_y_append_reset()
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4233,
/**/
4232,
/**/
Expand Down

0 comments on commit a4bc2dd

Please sign in to comment.