vim-patch:7.4.704

Problem:    Searching for a character matches an illegal byte and causes
            invalid memory access. (Dominique Pelle)
Solution:   Do not match an invalid byte when search for a character in a
            string.  Fix equivalence classes using negative numbers, which
            result in illegal bytes.

d82a2a990b
This commit is contained in:
Jurica Bradaric
2016-01-23 14:32:52 +01:00
parent 4172ce4eb0
commit ee56470157
3 changed files with 58 additions and 52 deletions

View File

@@ -425,9 +425,13 @@ char_u *vim_strchr(const char_u *string, int c)
const char_u *p = string;
if (enc_utf8 && c >= 0x80) {
while (*p != NUL) {
if (utf_ptr2char(p) == c)
int l = (*mb_ptr2len)(p);
// Avoid matching an illegal byte here.
if (utf_ptr2char(p) == c && l > 1) {
return (char_u *) p;
p += (*mb_ptr2len)(p);
}
p += l;
}
return NULL;
}