]> granicus.if.org Git - vim/commitdiff
patch 8.2.4968: reading past end of the line when C-indenting v8.2.4968
authorBram Moolenaar <Bram@vim.org>
Mon, 16 May 2022 17:06:15 +0000 (18:06 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 16 May 2022 17:06:15 +0000 (18:06 +0100)
Problem:    Reading past end of the line when C-indenting.
Solution:   Check for NUL.

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

index ec88036eb174eab13da9f4892202d590d22e668d..2d47e641be9c87b536f7c7de8362697527b8f69c 100644 (file)
@@ -89,7 +89,7 @@ skip_string(char_u *p)
                while (vim_isdigit(p[i - 1]))   // '\000'
                    ++i;
            }
-           if (p[i] == '\'')               // check for trailing '
+           if (p[i - 1] != NUL && p[i] == '\'')    // check for trailing '
            {
                p += i;
                continue;
index dbd4aa006e4f1853376ba0a137b287d5a7a0f555..c65a0dab33844a95f271a4ac855710b15f0f9ee1 100644 (file)
@@ -5319,6 +5319,13 @@ func Test_cindent_change_multline()
   close!
 endfunc
 
+" This was reading past the end of the line
+func Test_cindent_check_funcdecl()
+  new
+  sil norm o0\ f('\0\ f=L
+  bwipe!
+endfunc
+
 func Test_cindent_scopedecls()
   new
   setl cindent ts=4 sw=4
index 6359e0304d6232e16b3deff335be9416893f836e..7397e6fb71b8f917824479c3dd3bc15d29125e74 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4968,
 /**/
     4967,
 /**/