]> granicus.if.org Git - vim/commitdiff
patch 8.0.0333: illegal memory access when 'complete' ends in a backslash v8.0.0333
authorBram Moolenaar <Bram@vim.org>
Fri, 17 Feb 2017 13:53:15 +0000 (14:53 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 17 Feb 2017 13:53:15 +0000 (14:53 +0100)
Problem:    Illegal memory access when 'complete' ends in a backslash.
Solution:   Check for trailing backslash. (Dominique Pelle, closes #1478)

src/option.c
src/testdir/test_options.vim
src/version.c

index 32e97c99ba6e9acd98ae2e6d5e19b15dc8612548..b5f3a9a864418f99fa070532f54969c3b44402f6 100644 (file)
@@ -7017,7 +7017,7 @@ did_set_string_option(
                    /* skip optional filename after 'k' and 's' */
                    while (*s && *s != ',' && *s != ' ')
                    {
-                       if (*s == '\\')
+                       if (*s == '\\' && s[1] != NUL)
                            ++s;
                        ++s;
                    }
index ce59ae11b7f61f03f2b44d34c0cdff4ae2237972..31a87af70a1a45e30de062ebc77a081b19ebf219 100644 (file)
@@ -136,6 +136,15 @@ func Test_thesaurus()
   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', @:)
index 9bbdf2ec5ab449c0d567af644bfc283f3a228c00..dab99c76df736fc8d28b217238acf6015969d347 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    333,
 /**/
     332,
 /**/