patch 7.4.2356
Problem:    Reading past end of line when using previous substitute pattern.
            (Dominique Pelle)
Solution:   Don't set "pat" only set "searchstr".
diff --git a/src/search.c b/src/search.c
index bbda8ac..cb5caeb 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1240,14 +1240,13 @@
 	{
 	    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
 	    {
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index 9c2d610..3b9aff4 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -268,3 +268,14 @@
   call test_disable_char_avail(0)
   bw!
 endfunc
+
+func Test_use_sub_pat()
+  split
+  let @/ = ''
+  func X()
+    s/^/a/
+    /
+  endfunc
+  call X()
+  bwipe!
+endfunc
diff --git a/src/version.c b/src/version.c
index f332e43..baba587 100644
--- a/src/version.c
+++ b/src/version.c
@@ -764,6 +764,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2356,
+/**/
     2355,
 /**/
     2354,