]> granicus.if.org Git - vim/commitdiff
patch 8.2.3482: reading beyond end of line ending in quote and backslash v8.2.3482
authorBram Moolenaar <Bram@vim.org>
Tue, 5 Oct 2021 20:58:53 +0000 (21:58 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 5 Oct 2021 20:58:53 +0000 (21:58 +0100)
Problem:    Reading beyond end of line ending in quote and backslash.
Solution:   Check for non-NUL after backslash. (closes #8964)

src/cindent.c
src/testdir/test_cindent.vim
src/version.c

index b751206532353fdf91ec7161287eedb48706ae72..850a36994732cb52347a657ba57ab42b92a07f51 100644 (file)
@@ -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'
index 5926408d2e99976bcfb6f711065b688cb966ec49..3a536c4c89a54ea183aa6ff28219cca2c2ceba5c 100644 (file)
@@ -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
index 31fb2a618112c9422aa4651934431c585aa3eca6..b0049e00fb455ac0489f498a4057aa9ad07b9043 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3482,
 /**/
     3481,
 /**/