diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-07-29 16:22:25 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-07-29 16:22:25 +0100 |
commit | f50940531dd57135fe60aa393ac9d3281f352d88 (patch) | |
tree | 4c3b08270d0b6034ff8452dd490d00472163f1e2 /src/regexp.c | |
parent | 1e56bda9048a9625bce6e660938c834c5c15b07d (diff) |
patch 9.0.0105: illegal memory access when pattern starts with illegal bytev9.0.0105
Problem: Illegal memory access when pattern starts with illegal byte.
Solution: Do not match a character with an illegal byte.
Diffstat (limited to 'src/regexp.c')
-rw-r--r-- | src/regexp.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/regexp.c b/src/regexp.c index 1a5cfd07cb..bec046437f 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -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) |