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.
60ae0e7149
This commit is contained in:
zeertzjq 2022-05-17 08:07:51 +08:00
parent b8c0eeaa30
commit 26c906f54d
2 changed files with 8 additions and 1 deletions

View File

@ -150,7 +150,7 @@ static const char_u *skip_string(const char_u *p)
i++; i++;
} }
} }
if (p[i] == '\'') { // check for trailing ' if (p[i - 1] != NUL && p[i] == '\'') { // check for trailing '
p += i; p += i;
continue; continue;
} }

View File

@ -5311,6 +5311,13 @@ func Test_cindent_case()
bwipe! bwipe!
endfunc 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() func Test_cindent_scopedecls()
new new
setl cindent ts=4 sw=4 setl cindent ts=4 sw=4