diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-05-25 22:11:45 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-05-25 22:11:45 +0200 |
commit | adfde115d5c9c9ac4a052874bcf85d2507fe1355 (patch) | |
tree | 6f5c660848af238e11b72d819002da1d4cfc5909 | |
parent | a5e44600ebb02057fb15ae7a2f15c5cae8f63bcc (diff) | |
download | vim-git-adfde115d5c9c9ac4a052874bcf85d2507fe1355.tar.gz |
patch 8.1.1395: saving for undo may access invalid memoryv8.1.1395
Problem: Saving for undo may access invalid memory. (Dominique Pelle)
Solution: Set ml_line_len also when returning a constant string.
-rw-r--r-- | src/memline.c | 8 | ||||
-rw-r--r-- | src/testdir/test_textprop.vim | 9 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/memline.c b/src/memline.c index 35b524e6b..841625716 100644 --- a/src/memline.c +++ b/src/memline.c @@ -2573,13 +2573,17 @@ ml_get_buf( } errorret: STRCPY(IObuff, "???"); + buf->b_ml.ml_line_len = 4; return IObuff; } - if (lnum <= 0) /* pretend line 0 is line 1 */ + if (lnum <= 0) // pretend line 0 is line 1 lnum = 1; - if (buf->b_ml.ml_mfp == NULL) /* there are no lines */ + if (buf->b_ml.ml_mfp == NULL) // there are no lines + { + buf->b_ml.ml_line_len = 1; return (char_u *)""; + } /* * See if it is the same line as requested last time. diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim index 811ddf4d1..cb86186b4 100644 --- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -766,6 +766,15 @@ func Test_textprop_empty_buffer() new call prop_add(1, 1, {'type': 'comment'}) close + call prop_type_delete('comment') +endfunc + +" Adding a text property to an empty buffer and then editing another +func Test_textprop_empty_buffer_next() + call prop_type_add("xxx", {}) + call prop_add(1, 1, {"type": "xxx"}) + next X + call prop_type_delete('xxx') endfunc func Test_textprop_remove_from_buf() diff --git a/src/version.c b/src/version.c index 2d4c3c01d..3dad14128 100644 --- a/src/version.c +++ b/src/version.c @@ -768,6 +768,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1395, +/**/ 1394, /**/ 1393, |