From 26c906f54dafb37f7bc63e136a7a9373d1053fe1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 17 May 2022 08:07:51 +0800 Subject: [PATCH] vim-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. https://github.com/vim/vim/commit/60ae0e71490c97f2871a6344aca61cacf220f813 --- src/nvim/indent_c.c | 2 +- src/nvim/testdir/test_cindent.vim | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 6f75183a5a..e6dc985726 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -150,7 +150,7 @@ static const char_u *skip_string(const char_u *p) i++; } } - if (p[i] == '\'') { // check for trailing ' + if (p[i - 1] != NUL && p[i] == '\'') { // check for trailing ' p += i; continue; } diff --git a/src/nvim/testdir/test_cindent.vim b/src/nvim/testdir/test_cindent.vim index 4d69aed96c..7ba8ef3397 100644 --- a/src/nvim/testdir/test_cindent.vim +++ b/src/nvim/testdir/test_cindent.vim @@ -5311,6 +5311,13 @@ func Test_cindent_case() bwipe! 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