aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2015-09-08 13:03:09 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2015-09-18 14:35:26 -0300
commit0a116c828debc6192a6bfb6bceb8cf020e867db0 (patch)
treebc0b9b6e8d7e4c27ecb5ac19d487498ac3735986
parentc708061a5a9b1bb75f06c6de0b5c02f3a0abad4d (diff)
downloadrneovim-0a116c828debc6192a6bfb6bceb8cf020e867db0.tar.gz
rneovim-0a116c828debc6192a6bfb6bceb8cf020e867db0.tar.bz2
rneovim-0a116c828debc6192a6bfb6bceb8cf020e867db0.zip
regexp: Fix invalid multibyte reads at end of strings
Close #3150
-rw-r--r--src/nvim/regexp_nfa.c1
-rw-r--r--src/nvim/search.c2
2 files changed, 2 insertions, 1 deletions
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index 484dfe1e1f..4cd422400f 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -4781,6 +4781,7 @@ static long find_match_text(colnr_T startcol, int regstart, char_u *match_text)
if (match
/* check that no composing char follows */
&& !(enc_utf8
+ && STRLEN(regline) > (size_t)(col + len2)
&& utf_iscomposing(PTR2CHAR(regline + col + len2)))
) {
cleanup_subexpr();
diff --git a/src/nvim/search.c b/src/nvim/search.c
index ff5c5f834f..a758e02105 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -653,7 +653,7 @@ int searchit(
}
if (matchcol == 0 && (options & SEARCH_START))
break;
- if (ptr[matchcol] == NUL
+ if (STRLEN(ptr) <= (size_t)matchcol || ptr[matchcol] == NUL
|| (nmatched = vim_regexec_multi(&regmatch,
win, buf, lnum + matchpos.lnum,
matchcol,