vim-patch:8.2.5016: access before start of text with a put command (#18742)

Problem:    Access before start of text with a put command.
Solution:   Check the length is more than zero.
2a585c8501
This commit is contained in:
zeertzjq 2022-05-26 07:20:39 +08:00 committed by GitHub
parent 9fec6dc9a2
commit cbf57fa353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -3696,8 +3696,11 @@ error:
len = STRLEN(y_array[y_size - 1]);
col = (colnr_T)len - lendiff;
if (col > 1) {
curbuf->b_op_end.col = col - 1 - utf_head_off(y_array[y_size - 1],
y_array[y_size - 1] + len - 1);
curbuf->b_op_end.col = col - 1;
if (len > 0) {
curbuf->b_op_end.col -= utf_head_off(y_array[y_size - 1],
y_array[y_size - 1] + len - 1);
}
} else {
curbuf->b_op_end.col = 0;
}

View File

@ -203,3 +203,15 @@ func Test_multibyte_op_end_mark()
call assert_equal([0, 2, 7, 0], getpos("']"))
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