Skip to content

Commit baefde1

Browse files
committed
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
1 parent caea664 commit baefde1

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/insexpand.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,8 @@ ins_compl_add(
786786
{
787787
if (!match_at_original_text(match)
788788
&& STRNCMP(match->cp_str, str, len) == 0
789-
&& match->cp_str[len] == NUL)
789+
&& ((int)STRLEN(match->cp_str) <= len
790+
|| match->cp_str[len] == NUL))
790791
return NOTDONE;
791792
match = match->cp_next;
792793
} while (match != NULL && !is_first_match(match));

src/testdir/test_ins_complete.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,5 +2112,15 @@ func Test_infercase_very_long_line()
21122112
set noic noinfercase
21132113
endfunc
21142114

2115+
func Test_ins_complete_add()
2116+
" this was reading past the end of allocated memory
2117+
new
2118+
norm o
2119+
norm 7o€€
2120+
sil! norm o
2121+
2122+
bwipe!
2123+
endfunc
2124+
21152125

21162126
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,8 @@ static char *(features[]) =
735735

736736
static int included_patches[] =
737737
{ /* Add new patch number below this line */
738+
/**/
739+
46,
738740
/**/
739741
45,
740742
/**/

0 commit comments

Comments
 (0)