]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.0112: illegal memory access when using 'cindent' v8.2.0112
authorBram Moolenaar <Bram@vim.org>
Sun, 12 Jan 2020 12:48:18 +0000 (13:48 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 12 Jan 2020 12:48:18 +0000 (13:48 +0100)
Problem:    Illegal memory access when using 'cindent'.
Solution:   Check for NUL byte. (Dominique Pelle, closes #5470)

src/cindent.c
src/testdir/test_cindent.vim
src/version.c

index c7caed68f1717ac41fb7ac0a25ae8dac2a34599b..3dc7b1635485e1bfed1e78f15398be92390be4ea 100644 (file)
@@ -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++
index 2cb3f24b7a0d1ce186fcc483e195e6ff5fefd49d..2d78be1ad94e8a9c990c9bc7c31555a38d53f49f 100644 (file)
@@ -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
index 7941733cfff222bd8b74ca96e01e837bdc251ae3..508db61ef02d8fb47b62e3dd13e786ba6f964ebb 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    112,
 /**/
     111,
 /**/