forked from aniani/vim
patch 9.0.0483: illegal memory access when replacing in virtualedit mode
Problem: Illegal memory access when replacing in virtualedit mode. Solution: Check for replacing NUL after Tab.
This commit is contained in:
10
src/ops.c
10
src/ops.c
@@ -1173,6 +1173,8 @@ op_replace(oparg_T *oap, int c)
|
|||||||
|
|
||||||
while (LTOREQ_POS(curwin->w_cursor, oap->end))
|
while (LTOREQ_POS(curwin->w_cursor, oap->end))
|
||||||
{
|
{
|
||||||
|
int done = FALSE;
|
||||||
|
|
||||||
n = gchar_cursor();
|
n = gchar_cursor();
|
||||||
if (n != NUL)
|
if (n != NUL)
|
||||||
{
|
{
|
||||||
@@ -1186,6 +1188,7 @@ op_replace(oparg_T *oap, int c)
|
|||||||
if (curwin->w_cursor.lnum == oap->end.lnum)
|
if (curwin->w_cursor.lnum == oap->end.lnum)
|
||||||
oap->end.col += new_byte_len - old_byte_len;
|
oap->end.col += new_byte_len - old_byte_len;
|
||||||
replace_character(c);
|
replace_character(c);
|
||||||
|
done = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1204,10 +1207,15 @@ op_replace(oparg_T *oap, int c)
|
|||||||
if (curwin->w_cursor.lnum == oap->end.lnum)
|
if (curwin->w_cursor.lnum == oap->end.lnum)
|
||||||
getvpos(&oap->end, end_vcol);
|
getvpos(&oap->end, end_vcol);
|
||||||
}
|
}
|
||||||
|
// with "coladd" set may move to just after a TAB
|
||||||
|
if (gchar_cursor() != NUL)
|
||||||
|
{
|
||||||
PBYTE(curwin->w_cursor, c);
|
PBYTE(curwin->w_cursor, c);
|
||||||
|
done = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (virtual_op && curwin->w_cursor.lnum == oap->end.lnum)
|
}
|
||||||
|
if (!done && virtual_op && curwin->w_cursor.lnum == oap->end.lnum)
|
||||||
{
|
{
|
||||||
int virtcols = oap->end.coladd;
|
int virtcols = oap->end.coladd;
|
||||||
|
|
||||||
|
@@ -572,4 +572,18 @@ func Test_virtualedit_mouse()
|
|||||||
set virtualedit&
|
set virtualedit&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" this was replacing the NUL at the end of the line
|
||||||
|
func Test_virtualedit_replace_after_tab()
|
||||||
|
new
|
||||||
|
s/\v/ 0
|
||||||
|
set ve=all
|
||||||
|
let @" = ''
|
||||||
|
sil! norm vPvr0
|
||||||
|
|
||||||
|
call assert_equal("\t0", getline(1))
|
||||||
|
set ve&
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -703,6 +703,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
483,
|
||||||
/**/
|
/**/
|
||||||
482,
|
482,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user