summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-01-12 13:48:18 +0100
committerBram Moolenaar <Bram@vim.org>2020-01-12 13:48:18 +0100
commit02ad46394e8f887b60fda994f8a5da2ac1937b23 (patch)
tree88d500f542feded3c357c2d6c6afc1bdfee2a957
parent9b4a15d5dba354d2e1e02871470bad103f34769a (diff)
patch 8.2.0112: illegal memory access when using 'cindent'v8.2.0112
Problem: Illegal memory access when using 'cindent'. Solution: Check for NUL byte. (Dominique Pelle, closes #5470)
-rw-r--r--src/cindent.c2
-rw-r--r--src/testdir/test_cindent.vim9
-rw-r--r--src/version.c2
3 files changed, 13 insertions, 0 deletions
diff --git a/src/cindent.c b/src/cindent.c
index c7caed68f1..3dc7b16354 100644
--- a/src/cindent.c
+++ b/src/cindent.c
@@ -582,6 +582,8 @@ cin_iscase(
for (s += 4; *s; ++s)
{
s = cin_skipcomment(s);
+ if (*s == NUL)
+ break;
if (*s == ':')
{
if (s[1] == ':') // skip over "::" for C++
diff --git a/src/testdir/test_cindent.vim b/src/testdir/test_cindent.vim
index 2cb3f24b7a..2d78be1ad9 100644
--- a/src/testdir/test_cindent.vim
+++ b/src/testdir/test_cindent.vim
@@ -5251,4 +5251,13 @@ func Test_cindent_56()
enew! | close
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
diff --git a/src/version.c b/src/version.c
index 7941733cff..508db61ef0 100644
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 112,
+/**/
111,
/**/
110,