changeset 28891:85c2bbee17d0 v8.2.4968

patch 8.2.4968: reading past end of the line when C-indenting Commit: https://github.com/vim/vim/commit/60ae0e71490c97f2871a6344aca61cacf220f813 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 16 18:06:15 2022 +0100 patch 8.2.4968: reading past end of the line when C-indenting Problem: Reading past end of the line when C-indenting. Solution: Check for NUL.
author Bram Moolenaar <Bram@vim.org>
date Mon, 16 May 2022 19:15:03 +0200
parents 2a04de1b3d85
children 4df932719c00
files src/cindent.c src/testdir/test_cindent.vim src/version.c
diffstat 3 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/cindent.c
+++ b/src/cindent.c
@@ -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;
--- a/src/testdir/test_cindent.vim
+++ b/src/testdir/test_cindent.vim
@@ -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('\0=L
+  bwipe!
+endfunc
+
 func Test_cindent_scopedecls()
   new
   setl cindent ts=4 sw=4
--- 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 */
 /**/
+    4968,
+/**/
     4967,
 /**/
     4966,