1
0
forked from aniani/vim

patch 9.0.0046: reading past end of completion with duplicate match

Problem:    Reading past end of completion with duplicate match.
Solution:   Check string length
This commit is contained in:
Bram Moolenaar
2022-07-07 19:59:49 +01:00
parent caea66442d
commit baefde1455
3 changed files with 14 additions and 1 deletions

View File

@@ -786,7 +786,8 @@ ins_compl_add(
{ {
if (!match_at_original_text(match) if (!match_at_original_text(match)
&& STRNCMP(match->cp_str, str, len) == 0 && 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; return NOTDONE;
match = match->cp_next; match = match->cp_next;
} while (match != NULL && !is_first_match(match)); } while (match != NULL && !is_first_match(match));

View File

@@ -2112,5 +2112,15 @@ func Test_infercase_very_long_line()
set noic noinfercase set noic noinfercase
endfunc 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 " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -735,6 +735,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
46,
/**/ /**/
45, 45,
/**/ /**/