Skip to content

Commit 2fb8f68

Browse files
committed
patch 8.1.0555: crash when last search pat is set but not last substitute pat
Problem: Crash when last search pat is set but not last substitute pat. Solution: Do not mix up last search pattern and last subtitute pattern. (closes #3647)
1 parent 614ab8a commit 2fb8f68

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/search.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ do_search(
13851385
char_u *trunc;
13861386

13871387
if (*searchstr == NUL)
1388-
p = spats[last_idx].pat;
1388+
p = spats[0].pat;
13891389
else
13901390
p = searchstr;
13911391
msgbuf = alloc((unsigned)(STRLEN(p) + 40));

src/testdir/test_search.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,3 +1142,15 @@ func Test_search_sentence()
11421142
/\%'(
11431143
/
11441144
endfunc
1145+
1146+
" Test that there is no crash when there is a last search pattern but no last
1147+
" substitute pattern.
1148+
func Test_no_last_substitute_pat()
1149+
" Use viminfo to set the last search pattern to a string and make the last
1150+
" substitute pattern the most recent used and make it empty (NULL).
1151+
call writefile(['~MSle0/bar', '~MSle0~&'], 'Xviminfo')
1152+
rviminfo! Xviminfo
1153+
call assert_fails('normal n', 'E35:')
1154+
1155+
call delete('Xviminfo')
1156+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,8 @@ static char *(features[]) =
792792

793793
static int included_patches[] =
794794
{ /* Add new patch number below this line */
795+
/**/
796+
555,
795797
/**/
796798
554,
797799
/**/

0 commit comments

Comments
 (0)