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.
diff --git a/src/misc2.c b/src/misc2.c
index acb04b6..fc500e7 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -1885,9 +1885,12 @@
{
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;
}