diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-05-09 13:15:07 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-05-09 13:15:07 +0100 |
commit | 53a70289c2712808e6d4e88927e03cac01b470dd (patch) | |
tree | 2f0b1adfd8339a26ed38b85bbabd7cb4383d580b | |
parent | 0519ce00394474055bd58c089ea90a19986443eb (diff) |
patch 8.2.4925: trailing backslash may cause reading past end of linev8.2.4925
Problem: Trailing backslash may cause reading past end of line.
Solution: Check for NUL after backslash.
-rw-r--r-- | src/testdir/test_textobjects.vim | 10 | ||||
-rw-r--r-- | src/textobject.c | 4 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/testdir/test_textobjects.vim b/src/testdir/test_textobjects.vim index debbfb357b..34894d068a 100644 --- a/src/testdir/test_textobjects.vim +++ b/src/testdir/test_textobjects.vim @@ -185,10 +185,18 @@ func Test_string_html_objects() call assert_equal("<div><div\nattr=\"attr\"\n></div></div>", @", e) set quoteescape& + + " this was going beyond the end of the line + %del + sil! norm i"\ + sil! norm i"\ + sil! norm i"\ + call assert_equal('"\', getline(1)) + + bwipe! endfor set enc=utf-8 - bwipe! endfunc func Test_empty_html_tag() diff --git a/src/textobject.c b/src/textobject.c index e4a7db38ed..edaa64c51c 100644 --- a/src/textobject.c +++ b/src/textobject.c @@ -1664,7 +1664,11 @@ find_next_quote( if (c == NUL) return -1; else if (escape != NULL && vim_strchr(escape, c)) + { ++col; + if (line[col] == NUL) + return -1; + } else if (c == quotechar) break; if (has_mbyte) diff --git a/src/version.c b/src/version.c index d790a75403..8f33f05aac 100644 --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4925, +/**/ 4924, /**/ 4923, |