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.
diff --git a/src/cindent.c b/src/cindent.c
index ec88036..2d47e64 100644
--- a/src/cindent.c
+++ b/src/cindent.c
@@ -89,7 +89,7 @@
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;
diff --git a/src/testdir/test_cindent.vim b/src/testdir/test_cindent.vim
index dbd4aa0..c65a0da 100644
--- a/src/testdir/test_cindent.vim
+++ b/src/testdir/test_cindent.vim
@@ -5319,6 +5319,13 @@
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
diff --git a/src/version.c b/src/version.c
index 6359e03..7397e6f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4968,
+/**/
4967,
/**/
4966,