changeset 29408:c12fb2c5b1b3 v9.0.0046

patch 9.0.0046: reading past end of completion with duplicate match Commit: https://github.com/vim/vim/commit/baefde14550231f6468ac2ed2ed495bc381c0c92 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jul 7 19:59:49 2022 +0100 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
author Bram Moolenaar <Bram@vim.org>
date Thu, 07 Jul 2022 21:00:03 +0200
parents a46aa8d84416
children 928bf80ce1e8
files src/insexpand.c src/testdir/test_ins_complete.vim src/version.c
diffstat 3 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -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));
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -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
--- a/src/version.c
+++ b/src/version.c
@@ -736,6 +736,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    46,
+/**/
     45,
 /**/
     44,