Skip to content

Commit

Permalink
patch 8.2.5016: access before start of text with a put command
Browse files Browse the repository at this point in the history
Problem:    Access before start of text with a put command.
Solution:   Check the length is more than zero.
  • Loading branch information
brammool committed May 25, 2022
1 parent bf82df0 commit 2a585c8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/register.c
Expand Up @@ -2219,9 +2219,12 @@ do_put(
len = STRLEN(y_array[y_size - 1]);
col = (colnr_T)len - lendiff;
if (col > 1)
curbuf->b_op_end.col = col - 1
- mb_head_off(y_array[y_size - 1],
{
curbuf->b_op_end.col = col - 1;
if (len > 0)
curbuf->b_op_end.col -= mb_head_off(y_array[y_size - 1],
y_array[y_size - 1] + len - 1);
}
else
curbuf->b_op_end.col = 0;

Expand Down
9 changes: 9 additions & 0 deletions src/testdir/test_put.vim
Expand Up @@ -210,5 +210,14 @@ func Test_multibyte_op_end_mark()
bwipe!
endfunc

" this was putting a mark before the start of a line
func Test_put_empty_register()
new
norm yy
norm [Pi00ggv)s0
sil! norm [P
bwipe!
endfunc


" vim: shiftwidth=2 sts=2 expandtab
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -734,6 +734,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
5016,
/**/
5015,
/**/
Expand Down

0 comments on commit 2a585c8

Please sign in to comment.