summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/search.c6
-rw-r--r--src/testdir/test_search_stat.vim23
-rw-r--r--src/version.c2
3 files changed, 30 insertions, 1 deletions
diff --git a/src/search.c b/src/search.c
index 9c8cf95d8..1e4464b0c 100644
--- a/src/search.c
+++ b/src/search.c
@@ -3154,7 +3154,11 @@ cmdline_search_stat(
len += 2;
}
- mch_memmove(msgbuf + STRLEN(msgbuf) - len, t, len);
+ size_t msgbuf_len = STRLEN(msgbuf);
+ if (len > msgbuf_len)
+ len = msgbuf_len;
+ mch_memmove(msgbuf + msgbuf_len - len, t, len);
+
if (dirc == '?' && stat.cur == maxcount + 1)
stat.cur = -1;
diff --git a/src/testdir/test_search_stat.vim b/src/testdir/test_search_stat.vim
index b8509ba05..e205df574 100644
--- a/src/testdir/test_search_stat.vim
+++ b/src/testdir/test_search_stat.vim
@@ -270,6 +270,29 @@ func Test_searchcount_fails()
call assert_fails('echo searchcount({"pos" : [1, 2, []]})', 'E745:')
endfunc
+func Test_search_stat_narrow_screen()
+ " This used to crash Vim
+ let save_columns = &columns
+ try
+ let after =<< trim [CODE]
+ set laststatus=2
+ set columns=16
+ set shortmess-=S showcmd
+ call setline(1, 'abc')
+ call feedkeys("/abc\<CR>:quit!\<CR>")
+ autocmd VimLeavePre * call writefile(["done"], "Xdone")
+ [CODE]
+
+ if !RunVim([], after, '--clean')
+ return
+ endif
+ call assert_equal("done", readfile("Xdone")[0])
+ call delete('Xdone')
+ finally
+ let &columns = save_columns
+ endtry
+endfunc
+
func Test_searchcount_in_statusline()
CheckScreendump
diff --git a/src/version.c b/src/version.c
index ad663cd65..a79a9d0b5 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1270,
+/**/
1269,
/**/
1268,