aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-04-01 17:43:31 +0800
committerGitHub <noreply@github.com>2022-04-01 17:43:31 +0800
commit377e87521157947c384d470a63927719b8c73ad7 (patch)
tree3a2927ec6475311d48da2be51c59f2b5536afa89
parent88a4ac22f082e5c9d59acd8e9031908e1d2853c3 (diff)
parentb9454d1676999ae44faa070f79b40863e4ea843b (diff)
downloadrneovim-377e87521157947c384d470a63927719b8c73ad7.tar.gz
rneovim-377e87521157947c384d470a63927719b8c73ad7.tar.bz2
rneovim-377e87521157947c384d470a63927719b8c73ad7.zip
Merge pull request #17948 from zeertzjq/vim-8.2.3471
vim-patch:8.2.{3471,3472,3489}: fix some crashes/errors with search
-rw-r--r--src/nvim/ex_docmd.c5
-rw-r--r--src/nvim/ex_getln.c4
-rw-r--r--src/nvim/testdir/test_search.vim27
3 files changed, 34 insertions, 2 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 20325509c4..bb6f3ba395 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -4027,8 +4027,9 @@ static linenr_T get_address(exarg_T *eap, char_u **ptr, cmd_addr_T addr_type, in
// When '/' or '?' follows another address, start from
// there.
- if (lnum != MAXLNUM) {
- curwin->w_cursor.lnum = lnum;
+ if (lnum > 0 && lnum != MAXLNUM) {
+ curwin->w_cursor.lnum
+ = lnum > curbuf->b_ml.ml_line_count ? curbuf->b_ml.ml_line_count : lnum;
}
// Start a forward search at the end of the line (unless
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 1d02c74c41..9104a2dd5a 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -1606,6 +1606,10 @@ static int may_do_command_line_next_incsearch(int firstc, long count, incsearch_
if (search_delim == ccline.cmdbuff[skiplen]) {
pat = last_search_pattern();
+ if (pat == NULL) {
+ restore_last_search_pattern();
+ return FAIL;
+ }
skiplen = 0;
patlen = (int)STRLEN(pat);
} else {
diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim
index a3d5ca96a1..8154bd9c4d 100644
--- a/src/nvim/testdir/test_search.vim
+++ b/src/nvim/testdir/test_search.vim
@@ -1527,4 +1527,31 @@ func Test_incsearch_highlighting_newline()
bw
endfunc
+func Test_no_last_search_pattern()
+ CheckOption incsearch
+
+ let @/ = ""
+ set incsearch
+ " these were causing a crash
+ call feedkeys("//\<C-G>", 'xt')
+ call feedkeys("//\<C-T>", 'xt')
+ call feedkeys("??\<C-G>", 'xt')
+ call feedkeys("??\<C-T>", 'xt')
+endfunc
+
+func Test_search_with_invalid_range()
+ new
+ let lines =<< trim END
+ /\%.v
+ 5/
+ c
+ END
+ call writefile(lines, 'Xrangesearch')
+ source Xrangesearch
+
+ bwipe!
+ call delete('Xrangesearch')
+endfunc
+
+
" vim: shiftwidth=2 sts=2 expandtab