Skip to content

Commit 02ad463

Browse files
committed
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 #5470)
1 parent 9b4a15d commit 02ad463

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/cindent.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,8 @@ cin_iscase(
582582
for (s += 4; *s; ++s)
583583
{
584584
s = cin_skipcomment(s);
585+
if (*s == NUL)
586+
break;
585587
if (*s == ':')
586588
{
587589
if (s[1] == ':') // skip over "::" for C++

src/testdir/test_cindent.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5251,4 +5251,13 @@ func Test_cindent_56()
52515251
enew! | close
52525252
endfunc
52535253

5254+
" this was going beyond the end of the line.
5255+
func Test_cindent_case()
5256+
new
5257+
call setline(1, "case x: // x")
5258+
set cindent
5259+
norm! f:a:
5260+
bwipe!
5261+
endfunc
5262+
52545263
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,8 @@ static char *(features[]) =
742742

743743
static int included_patches[] =
744744
{ /* Add new patch number below this line */
745+
/**/
746+
112,
745747
/**/
746748
111,
747749
/**/

0 commit comments

Comments
 (0)