diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-19 23:53:15 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-20 00:05:12 -0400 |
commit | 1d2b7020087626ab6e8bd43a203f14f9d1cdd31a (patch) | |
tree | 9abceeaa16a9f0bdfb6baed2cb6c7c373ab8819f /src/nvim/search.c | |
parent | 2c0998e104bb94bcc52f3aaa37747477fbe59782 (diff) | |
download | rneovim-1d2b7020087626ab6e8bd43a203f14f9d1cdd31a.tar.gz rneovim-1d2b7020087626ab6e8bd43a203f14f9d1cdd31a.tar.bz2 rneovim-1d2b7020087626ab6e8bd43a203f14f9d1cdd31a.zip |
vim-patch:8.0.1486: accessing invalid memory with "it"
Problem: Accessing invalid memory with "it". (Dominique Pelle)
Solution: Avoid going over the end of the line. (Christian Brabandt,
closes vim/vim#2532)
https://github.com/vim/vim/commit/82846a00ac0c135946c93c48c1657018a5c96b11
Diffstat (limited to 'src/nvim/search.c')
-rw-r--r-- | src/nvim/search.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c index dc4ae2e847..2ecc8da09e 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -570,8 +570,12 @@ int searchit( && pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count && pos->col < MAXCOL - 2) { // Watch out for the "col" being MAXCOL - 2, used in a closed fold. - ptr = ml_get_buf(buf, pos->lnum, false) + pos->col; - start_char_len = *ptr == NUL ? 1 : (*mb_ptr2len)(ptr); + ptr = ml_get_buf(buf, pos->lnum, false); + if ((int)STRLEN(ptr) < pos->col) { + start_char_len = 1; + } else { + start_char_len = utfc_ptr2len(ptr + pos->col); + } } else { start_char_len = 1; } |