aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-01-12 18:40:27 -0500
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-01-17 19:06:50 -0500
commit03da3697a40d56961250028ce60a49ea6e87728b (patch)
treeb83c6e6fd607de06509d39bdd2dca13068fdc598 /src
parentfd89ad7bfb1534c42c99b36ca025ea42ccbee7e1 (diff)
downloadrneovim-03da3697a40d56961250028ce60a49ea6e87728b.tar.gz
rneovim-03da3697a40d56961250028ce60a49ea6e87728b.tar.bz2
rneovim-03da3697a40d56961250028ce60a49ea6e87728b.zip
vim-patch:8.2.0112: illegal memory access when using 'cindent'
Problem: Illegal memory access when using 'cindent'. Solution: Check for NUL byte. (Dominique Pelle, closes vim/vim#5470) https://github.com/vim/vim/commit/02ad46394e8f887b60fda994f8a5da2ac1937b23
Diffstat (limited to 'src')
-rw-r--r--src/nvim/indent_c.c3
-rw-r--r--src/nvim/testdir/test_cindent.vim9
2 files changed, 12 insertions, 0 deletions
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 1ca1f3dae5..67a7e58ed7 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -461,6 +461,9 @@ cin_iscase (
if (cin_starts_with(s, "case")) {
for (s += 4; *s; ++s) {
s = cin_skipcomment(s);
+ if (*s == NUL) {
+ break;
+ }
if (*s == ':') {
if (s[1] == ':') /* skip over "::" for C++ */
++s;
diff --git a/src/nvim/testdir/test_cindent.vim b/src/nvim/testdir/test_cindent.vim
index d9795d9335..debc9da46d 100644
--- a/src/nvim/testdir/test_cindent.vim
+++ b/src/nvim/testdir/test_cindent.vim
@@ -118,4 +118,13 @@ b = something();
bw!
endfunc
+" this was going beyond the end of the line.
+func Test_cindent_case()
+ new
+ call setline(1, "case x: // x")
+ set cindent
+ norm! f:a:
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab