Skip to content

Commit

Permalink
patch 9.0.0046: reading past end of completion with duplicate match
Browse files Browse the repository at this point in the history
Problem:    Reading past end of completion with duplicate match.
Solution:   Check string length
  • Loading branch information
brammool committed Jul 7, 2022
1 parent caea664 commit baefde1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/insexpand.c
Expand Up @@ -786,7 +786,8 @@ ins_compl_add(
{
if (!match_at_original_text(match)
&& STRNCMP(match->cp_str, str, len) == 0
&& match->cp_str[len] == NUL)
&& ((int)STRLEN(match->cp_str) <= len
|| match->cp_str[len] == NUL))
return NOTDONE;
match = match->cp_next;
} while (match != NULL && !is_first_match(match));
Expand Down
10 changes: 10 additions & 0 deletions src/testdir/test_ins_complete.vim
Expand Up @@ -2112,5 +2112,15 @@ func Test_infercase_very_long_line()
set noic noinfercase
endfunc

func Test_ins_complete_add()
" this was reading past the end of allocated memory
new
norm o
norm 7o€€
sil! norm o

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 */
/**/
46,
/**/
45,
/**/
Expand Down

0 comments on commit baefde1

Please sign in to comment.