diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-02-09 18:09:54 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-02-09 18:09:54 +0100 |
commit | 82846a00ac0c135946c93c48c1657018a5c96b11 (patch) | |
tree | 21306ce00ffd7e80682c54a9a4ca6f1a0f0d9333 | |
parent | 9e33efd1523b85a70533930dd43a26925a2b648c (diff) |
patch 8.0.1486: accessing invalid memory with "it"v8.0.1486
Problem: Accessing invalid memory with "it". (Dominique Pelle)
Solution: Avoid going over the end of the line. (Christian Brabandt,
closes #2532)
-rw-r--r-- | src/search.c | 6 | ||||
-rw-r--r-- | src/testdir/test_textobjects.vim | 13 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 18 insertions, 3 deletions
diff --git a/src/search.c b/src/search.c index efcf3d96a4..8089dcf369 100644 --- a/src/search.c +++ b/src/search.c @@ -684,11 +684,11 @@ searchit( && pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count && pos->col < MAXCOL - 2) { - ptr = ml_get_buf(buf, pos->lnum, FALSE) + pos->col; - if (*ptr == NUL) + ptr = ml_get_buf(buf, pos->lnum, FALSE); + if ((int)STRLEN(ptr) < pos->col) start_char_len = 1; else - start_char_len = (*mb_ptr2len)(ptr); + start_char_len = (*mb_ptr2len)(ptr + pos->col); } #endif else diff --git a/src/testdir/test_textobjects.vim b/src/testdir/test_textobjects.vim index 684f197f5f..17602fbe26 100644 --- a/src/testdir/test_textobjects.vim +++ b/src/testdir/test_textobjects.vim @@ -152,3 +152,16 @@ func Test_match() call assert_equal(3 , match('abc', '\zs', 3, 1)) call assert_equal(-1, match('abc', '\zs', 4, 1)) endfunc + +" This was causing an illegal memory access +func Test_inner_tag() + new + norm ixxx + call feedkeys("v", 'xt') + insert +x +x +. + norm it + q! +endfunc diff --git a/src/version.c b/src/version.c index 963f611fa5..d3927cbd0b 100644 --- a/src/version.c +++ b/src/version.c @@ -772,6 +772,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1486, +/**/ 1485, /**/ 1484, |