diff options
author | Bram Moolenaar <Bram@vim.org> | 2015-04-21 14:02:35 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2015-04-21 14:02:35 +0200 |
commit | d82a2a990bc329754e1b61c5af669c76ac202497 (patch) | |
tree | b7655ae9701795e9646749c9b0a08a7b0de43a49 /src/misc2.c | |
parent | f9bde2b152d3344c694c5e1ca629156b34f1a627 (diff) | |
download | vim-git-d82a2a990bc329754e1b61c5af669c76ac202497.tar.gz |
patch 7.4.704v7.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.
Diffstat (limited to 'src/misc2.c')
-rw-r--r-- | src/misc2.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/misc2.c b/src/misc2.c index acb04b616..fc500e7d4 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -1885,9 +1885,12 @@ vim_strchr(string, c) { 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; } |