changeset 25897:f2fb5d30cd16 v8.2.3482

patch 8.2.3482: reading beyond end of line ending in quote and backslash Commit: https://github.com/vim/vim/commit/78e0fa4cf4fcd563c0bc8c87afa54d4f5dc22020 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Oct 5 21:58:53 2021 +0100 patch 8.2.3482: reading beyond end of line ending in quote and backslash Problem: Reading beyond end of line ending in quote and backslash. Solution: Check for non-NUL after backslash. (closes https://github.com/vim/vim/issues/8964)
author Bram Moolenaar <Bram@vim.org>
date Tue, 05 Oct 2021 23:00:05 +0200
parents 3a3defdbc05c
children 0c4a3229ffa0
files src/cindent.c src/testdir/test_cindent.vim src/version.c
diffstat 3 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/cindent.c
+++ b/src/cindent.c
@@ -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'
--- a/src/testdir/test_cindent.vim
+++ b/src/testdir/test_cindent.vim
@@ -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
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3482,
+/**/
     3481,
 /**/
     3480,