Mercurial > vim
comparison src/regexp.c @ 29527:e7158d889784 v9.0.0105
patch 9.0.0105: illegal memory access when pattern starts with illegal byte
Commit: https://github.com/vim/vim/commit/f50940531dd57135fe60aa393ac9d3281f352d88
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jul 29 16:22:25 2022 +0100
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 29 Jul 2022 17:30:03 +0200 |
parents | 057c26b5c33a |
children | a63d3a0e9aba |
comparison
equal
deleted
inserted
replaced
29526:575f2686d4a8 | 29527:e7158d889784 |
---|---|
1639 { | 1639 { |
1640 for (p = s; *p != NUL; p += (*mb_ptr2len)(p)) | 1640 for (p = s; *p != NUL; p += (*mb_ptr2len)(p)) |
1641 { | 1641 { |
1642 if (enc_utf8 && c > 0x80) | 1642 if (enc_utf8 && c > 0x80) |
1643 { | 1643 { |
1644 if (utf_fold(utf_ptr2char(p)) == cc) | 1644 int uc = utf_ptr2char(p); |
1645 | |
1646 // Do not match an illegal byte. E.g. 0xff matches 0xc3 0xbf, | |
1647 // not 0xff. | |
1648 if ((uc < 0x80 || uc != *p) && utf_fold(uc) == cc) | |
1645 return p; | 1649 return p; |
1646 } | 1650 } |
1647 else if (*p == c || *p == cc) | 1651 else if (*p == c || *p == cc) |
1648 return p; | 1652 return p; |
1649 } | 1653 } |