aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-05-17 08:07:51 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-05-17 08:16:31 +0800
commit26c906f54dafb37f7bc63e136a7a9373d1053fe1 (patch)
tree50be4d79dea38d308f0b69d668f5ba912afb2947
parentb8c0eeaa30c478c1017ee16919d7cb263e70e8f3 (diff)
downloadrneovim-26c906f54dafb37f7bc63e136a7a9373d1053fe1.tar.gz
rneovim-26c906f54dafb37f7bc63e136a7a9373d1053fe1.tar.bz2
rneovim-26c906f54dafb37f7bc63e136a7a9373d1053fe1.zip
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
-rw-r--r--src/nvim/indent_c.c2
-rw-r--r--src/nvim/testdir/test_cindent.vim7
2 files changed, 8 insertions, 1 deletions
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