From: Bram Moolenaar Date: Sat, 4 Mar 2023 14:13:10 +0000 (+0000) Subject: patch 9.0.1378: illegal memory access when using virtual editing X-Git-Tag: v9.0.1378 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c99cbf8f289bdda5d4a77d7ec415850a520330ba;p=vim patch 9.0.1378: illegal memory access when using virtual editing Problem: Illegal memory access when using virtual editing. Solution: Make sure "startspaces" is not negative. --- diff --git a/src/register.c b/src/register.c index 461363be3..f3df79cfd 100644 --- a/src/register.c +++ b/src/register.c @@ -1245,6 +1245,8 @@ op_yank(oparg_T *oap, int deleting, int mess) // double-count it. bd.startspaces = (ce - cs + 1) - oap->start.coladd; + if (bd.startspaces < 0) + bd.startspaces = 0; startcol++; } } diff --git a/src/testdir/test_virtualedit.vim b/src/testdir/test_virtualedit.vim index 71cea427b..edaae6786 100644 --- a/src/testdir/test_virtualedit.vim +++ b/src/testdir/test_virtualedit.vim @@ -88,6 +88,16 @@ func Test_edit_change() set virtualedit= endfunc +func Test_edit_special_char() + new + se ve=all + norm a0 + sil! exe "norm o00000\k