forked from aniani/vim
patch 9.0.0105: illegal memory access when pattern starts with illegal byte
Problem: Illegal memory access when pattern starts with illegal byte. Solution: Do not match a character with an illegal byte.
This commit is contained in:
@@ -1641,7 +1641,11 @@ cstrchr(char_u *s, int c)
|
||||
{
|
||||
if (enc_utf8 && c > 0x80)
|
||||
{
|
||||
if (utf_fold(utf_ptr2char(p)) == cc)
|
||||
int uc = utf_ptr2char(p);
|
||||
|
||||
// Do not match an illegal byte. E.g. 0xff matches 0xc3 0xbf,
|
||||
// not 0xff.
|
||||
if ((uc < 0x80 || uc != *p) && utf_fold(uc) == cc)
|
||||
return p;
|
||||
}
|
||||
else if (*p == c || *p == cc)
|
||||
|
Reference in New Issue
Block a user