patch 8.0.0333: illegal memory access when 'complete' ends in a backslash
Problem: Illegal memory access when 'complete' ends in a backslash.
Solution: Check for trailing backslash. (Dominique Pelle, closes #1478)
diff --git a/src/option.c b/src/option.c
index 32e97c9..b5f3a9a 100644
--- a/src/option.c
+++ b/src/option.c
@@ -7017,7 +7017,7 @@
/* skip optional filename after 'k' and 's' */
while (*s && *s != ',' && *s != ' ')
{
- if (*s == '\\')
+ if (*s == '\\' && s[1] != NUL)
++s;
++s;
}
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index ce59ae1..31a87af 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -136,6 +136,15 @@
call Check_dir_option('thesaurus')
endfun
+func Test_complete()
+ " Trailing single backslash used to cause invalid memory access.
+ set complete=s\
+ new
+ call feedkeys("i\<C-N>\<Esc>", 'xt')
+ bwipe!
+ set complete&
+endfun
+
func Test_set_completion()
call feedkeys(":set di\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set dictionary diff diffexpr diffopt digraph directory display', @:)
diff --git a/src/version.c b/src/version.c
index 9bbdf2e..dab99c7 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 333,
+/**/
332,
/**/
331,