mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
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.
This commit is contained in:
@@ -1885,9 +1885,12 @@ vim_strchr(string, c)
|
||||
{
|
||||
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 p;
|
||||
p += (*mb_ptr2len)(p);
|
||||
p += l;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user