From 60ae0e71490c97f2871a6344aca61cacf220f813 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 16 May 2022 18:06:15 +0100 Subject: [PATCH] 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. --- src/cindent.c | 2 +- src/testdir/test_cindent.vim | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cindent.c b/src/cindent.c index 28d1558..1b2763f 100644 --- a/src/cindent.c +++ b/src/cindent.c @@ -91,7 +91,7 @@ skip_string(char_u *p) while (vim_isdigit(p[i - 1])) // '\000' ++i; } - if (p[i] == '\'') // check for trailing ' + if (p[i - 1] != NUL && p[i] == '\'') // check for trailing ' { p += i; continue; diff --git a/src/testdir/test_cindent.vim b/src/testdir/test_cindent.vim index 2a87460..3b2200a 100644 --- a/src/testdir/test_cindent.vim +++ b/src/testdir/test_cindent.vim @@ -5263,4 +5263,11 @@ func Test_find_brace_backwards() endfunc +" This was reading past the end of the line +func Test_cindent_check_funcdecl() + new + sil norm o0('\0=L + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- 1.8.3.1