From 649a11bc139d109e8a3adc893a9e53ab32cf248c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 1 Apr 2022 17:08:04 +0800 Subject: vim-patch:8.2.3471: crash when using CTRL-T after an empty search pattern Problem: Crash when using CTRL-T after an empty search pattern. Solution: Bail out when there is no previous search pattern. (closes vim/vim#8953) https://github.com/vim/vim/commit/d8d957de86f218de9124ca1209548f8c6f61b69b --- src/nvim/ex_getln.c | 4 ++++ src/nvim/testdir/test_search.vim | 10 ++++++++++ 2 files changed, 14 insertions(+) (limited to 'src') 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..f88017388a 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -1527,4 +1527,14 @@ func Test_incsearch_highlighting_newline() bw endfunc +func Test_no_last_search_pattern() + CheckOption incsearch + + let @/ = "" + set incsearch + " this was causing a crash + call feedkeys("//\x14", 'xt') +endfunc + + " vim: shiftwidth=2 sts=2 expandtab -- cgit From b8fbd749a9d814f227c26d02f17f805435856677 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 1 Apr 2022 17:12:09 +0800 Subject: vim-patch:8.2.3472: other crashes with empty search pattern not tested MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Other crashes with empty search pattern not tested. Solution: Add a few more test lines. (Dominique Pellé) https://github.com/vim/vim/commit/9af9fd6ab637ea507dd9015fa5a84a408c36c1e0 --- src/nvim/testdir/test_search.vim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index f88017388a..040267c136 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -1532,8 +1532,11 @@ func Test_no_last_search_pattern() let @/ = "" set incsearch - " this was causing a crash - call feedkeys("//\x14", 'xt') + " these were causing a crash + call feedkeys("//\", 'xt') + call feedkeys("//\", 'xt') + call feedkeys("??\", 'xt') + call feedkeys("??\", 'xt') endfunc -- cgit From b9454d1676999ae44faa070f79b40863e4ea843b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 1 Apr 2022 17:12:41 +0800 Subject: vim-patch:8.2.3489: ml_get error after search with range Problem: ml_get error after search with range. Solution: Limit the line number to the buffer line count. https://github.com/vim/vim/commit/35a319b77f897744eec1155b736e9372c9c5575f --- src/nvim/ex_docmd.c | 5 +++-- src/nvim/testdir/test_search.vim | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src') 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/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 040267c136..8154bd9c4d 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -1539,5 +1539,19 @@ func Test_no_last_search_pattern() call feedkeys("??\", '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 -- cgit