Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
patch 9.0.0020: with some completion reading past end of string
Problem:    With some completion reading past end of string.
Solution:   Check the length of the string.
  • Loading branch information
brammool committed Jul 1, 2022
1 parent eb273cd commit f12129f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/insexpand.c
Expand Up @@ -2209,11 +2209,21 @@ ins_compl_stop(int c, int prev_mode, int retval)
// but only do this, if the Popup is still visible
if (c == Ctrl_E)
{
char_u *p = NULL;

ins_compl_delete();
if (compl_leader != NULL)
ins_bytes(compl_leader + get_compl_len());
p = compl_leader;
else if (compl_first_match != NULL)
ins_bytes(compl_orig_text + get_compl_len());
p = compl_orig_text;
if (p != NULL)
{
int compl_len = get_compl_len();
int len = (int)STRLEN(p);

if (len > compl_len)
ins_bytes_len(p + compl_len, len - compl_len);
}
retval = TRUE;
}

Expand Down
8 changes: 8 additions & 0 deletions src/testdir/test_ins_complete.vim
Expand Up @@ -2184,4 +2184,12 @@ func Test_complete_smartindent()
delfunction! FooBarComplete
endfunc

func Test_complete_overrun()
" this was going past the end of the copied text
new
sil norm si”0s0 
bwipe!
endfunc


" vim: shiftwidth=2 sts=2 expandtab
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -735,6 +735,8 @@ static char *(features[]) =

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

0 comments on commit f12129f

Please sign in to comment.