diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-10-02 22:46:54 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-10-02 23:13:28 -0400 |
commit | 2000e1621d5e529d660dc0a7534f0884b6179c8b (patch) | |
tree | 9b08b81e8e79d9119b34b241c44ad55b76373a08 | |
parent | 25513049b3c3f9276dfa560ef0920f3ed6cc5f2f (diff) | |
download | rneovim-2000e1621d5e529d660dc0a7534f0884b6179c8b.tar.gz rneovim-2000e1621d5e529d660dc0a7534f0884b6179c8b.tar.bz2 rneovim-2000e1621d5e529d660dc0a7534f0884b6179c8b.zip |
vim-patch:8.2.1787: crash with 'incsearch' and very long line
Problem: Crash with 'incsearch' and very long line.
Solution: Check whether regprog becomes NULL. (closes vim/vim#7063)
https://github.com/vim/vim/commit/795aaa1e84d76a6fe066694de9876b8a21cbe40c
N/A patches for version.c:
vim-patch:8.2.1784: commits are not scanned for security problems
Problem: commits are not scanned for security problems
Solution: Enable Github code scanning. (Christian Brabandt, closes vim/vim#7057)
https://github.com/vim/vim/commit/fa79be6b10e1d34fd697a56e85f6c0ce101f3d62
-rw-r--r-- | src/nvim/search.c | 27 | ||||
-rw-r--r-- | src/nvim/testdir/test_search.vim | 15 |
2 files changed, 37 insertions, 5 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c index b053459c7f..ea2107c5c7 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -651,6 +651,10 @@ int searchit( colnr_T col = at_first_line && (options & SEARCH_COL) ? pos->col : 0; nmatched = vim_regexec_multi(®match, win, buf, lnum, col, tm, timed_out); + // vim_regexec_multi() may clear "regprog" + if (regmatch.regprog == NULL) { + break; + } // Abort searching on an error (e.g., out of stack). if (called_emsg || (timed_out != NULL && *timed_out)) { break; @@ -722,6 +726,10 @@ int searchit( match_ok = false; break; } + // vim_regexec_multi() may clear "regprog" + if (regmatch.regprog == NULL) { + break; + } matchpos = regmatch.startpos[0]; endpos = regmatch.endpos[0]; submatch = first_submatch(®match); @@ -811,10 +819,13 @@ int searchit( } break; } - - /* Need to get the line pointer again, a - * multi-line search may have made it invalid. */ - ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE); + // vim_regexec_multi() may clear "regprog" + if (regmatch.regprog == NULL) { + break; + } + // Need to get the line pointer again, a + // multi-line search may have made it invalid. + ptr = ml_get_buf(buf, lnum + matchpos.lnum, false); } /* @@ -891,6 +902,11 @@ int searchit( } at_first_line = FALSE; + // vim_regexec_multi() may clear "regprog" + if (regmatch.regprog == NULL) { + break; + } + // Stop the search if wrapscan isn't set, "stop_lnum" is // specified, after an interrupt, after a match and after looping // twice. @@ -4243,7 +4259,8 @@ is_zero_width(char_u *pattern, int move, pos_T *cur, Direction direction) if (nmatched != 0) { break; } - } while (direction == FORWARD + } while (regmatch.regprog != NULL + && direction == FORWARD ? regmatch.startpos[0].col < pos.col : regmatch.startpos[0].col > pos.col); diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 211fc73562..5db23c22a8 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -981,6 +981,21 @@ func Test_incsearch_substitute() call Incsearch_cleanup() endfunc +func Test_incsearch_substitute_long_line() + throw 'skipped: Nvim does not support test_override()' + new + call test_override("char_avail", 1) + set incsearch + + call repeat('x', 100000)->setline(1) + call feedkeys(':s/\%c', 'xt') + redraw + call feedkeys("\<Esc>", 'xt') + + call Incsearch_cleanup() + bwipe! +endfunc + func Test_search_undefined_behaviour() if !has("terminal") return |