diff options
Diffstat (limited to 'src/nvim/strings.c')
-rw-r--r-- | src/nvim/strings.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/nvim/strings.c b/src/nvim/strings.c index fe91141375..30a9052a1e 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -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; } |