regexp: Fix invalid multibyte reads at end of strings

Close #3150
This commit is contained in:
Thiago de Arruda 2015-09-08 13:03:09 -03:00
parent c708061a5a
commit 0a116c828d
2 changed files with 2 additions and 1 deletions

View File

@ -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();

View File

@ -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,