diff options
author | Daniel Hahler <git@thequod.de> | 2018-02-10 22:40:43 +0100 |
---|---|---|
committer | Daniel Hahler <git@thequod.de> | 2018-02-10 22:49:42 +0100 |
commit | d929a41f5f8021fdb227c1fed1463094f16d305e (patch) | |
tree | 7021a0849a73d76e31b2ea17d81b35da9c91e388 /src | |
parent | 34b99bc06b1e836f3a9bdfc25d55ff0661049007 (diff) | |
download | rneovim-d929a41f5f8021fdb227c1fed1463094f16d305e.tar.gz rneovim-d929a41f5f8021fdb227c1fed1463094f16d305e.tar.bz2 rneovim-d929a41f5f8021fdb227c1fed1463094f16d305e.zip |
vim-patch:8.0.1483: searchpair() might return an invalid value on timeout
Problem: Searchpair() might return an invalid value on timeout.
Solution: When the second search times out, do not accept a match from the
first search. (Daniel Hahler, closes vim/vim#2552)
https://github.com/vim/vim/commit/9d32276b52a63fccfae681f0d1d6ccb66efec1c0
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/search.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c index bbcac45369..533a28de35 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -775,12 +775,17 @@ int searchit( } } if (ptr[matchcol] == NUL - || (nmatched = vim_regexec_multi(®match, - win, buf, lnum + matchpos.lnum, - matchcol, - tm - )) == 0) - break; + || (nmatched = vim_regexec_multi( + ®match, win, buf, lnum + matchpos.lnum, matchcol, + tm)) == 0) { + // If the search timed out, we did find a match + // but it might be the wrong one, so that's not + // OK. + if (tm != NULL && profile_passed_limit(*tm)) { + match_ok = false; + } + break; + } /* Need to get the line pointer again, a * multi-line search may have made it invalid. */ |