Skip to content

Commit

Permalink
patch 8.2.3482: reading beyond end of line ending in quote and backslash
Browse files Browse the repository at this point in the history
Problem:    Reading beyond end of line ending in quote and backslash.
Solution:   Check for non-NUL after backslash. (closes #8964)
  • Loading branch information
brammool committed Oct 5, 2021
1 parent 2e258bd commit 78e0fa4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cindent.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ skip_string(char_u *p)
{
if (p[0] == '\'') // 'c' or '\n' or '\000'
{
if (!p[1]) // ' at end of line
if (p[1] == NUL) // ' at end of line
break;
i = 2;
if (p[1] == '\\') // '\n' or '\000'
if (p[1] == '\\' && p[2] != NUL) // '\n' or '\000'
{
++i;
while (vim_isdigit(p[i - 1])) // '\000'
Expand Down
7 changes: 7 additions & 0 deletions src/testdir/test_cindent.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5307,4 +5307,11 @@ func Test_cindent_pragma()
enew! | close
endfunc

func Test_backslash_at_end_of_line()
new
exe "norm v>O'\\\<C-m>-"
exe "norm \<C-q>="
bwipe!
endfunc

" vim: shiftwidth=2 sts=2 expandtab
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3482,
/**/
3481,
/**/
Expand Down

0 comments on commit 78e0fa4

Please sign in to comment.