From 0a116c828debc6192a6bfb6bceb8cf020e867db0 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Tue, 8 Sep 2015 13:03:09 -0300 Subject: regexp: Fix invalid multibyte reads at end of strings Close #3150 --- src/nvim/regexp_nfa.c | 1 + src/nvim/search.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') 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(®match, win, buf, lnum + matchpos.lnum, matchcol, -- cgit