]> granicus.if.org Git - vim/commitdiff
patch 7.4.2356 v7.4.2356
authorBram Moolenaar <Bram@vim.org>
Fri, 9 Sep 2016 19:41:34 +0000 (21:41 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 9 Sep 2016 19:41:34 +0000 (21:41 +0200)
Problem:    Reading past end of line when using previous substitute pattern.
            (Dominique Pelle)
Solution:   Don't set "pat" only set "searchstr".

src/search.c
src/testdir/test_search.vim
src/version.c

index bbda8acce2bacc1309bc03b6f842f915da0dcb0a..cb5caeb6da002f9e67df0cdf7dbb848fb09682ba 100644 (file)
@@ -1240,14 +1240,13 @@ do_search(
        {
            if (spats[RE_SEARCH].pat == NULL)       /* no previous pattern */
            {
-               pat = spats[RE_SUBST].pat;
-               if (pat == NULL)
+               searchstr = spats[RE_SUBST].pat;
+               if (searchstr == NULL)
                {
                    EMSG(_(e_noprevre));
                    retval = 0;
                    goto end_do_search;
                }
-               searchstr = pat;
            }
            else
            {
index 9c2d6105130f7f2c9646afdce0fa2cbfb96d2cc6..3b9aff4e7daf03fe29887d2fbedcc38dba4ae237 100644 (file)
@@ -268,3 +268,14 @@ func Test_search_cmdline2()
   call test_disable_char_avail(0)
   bw!
 endfunc
+
+func Test_use_sub_pat()
+  split
+  let @/ = ''
+  func X()
+    s/^/a/
+    /
+  endfunc
+  call X()
+  bwipe!
+endfunc
index f332e43e9bbdd64d470287a825211f9ef6d10e32..baba587cb13447076930720049cf3a6cee3ffb06 100644 (file)
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2356,
 /**/
     2355,
 /**/