mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 06:18:16 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user