mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 19:25:11 -07:00
vim-patch:9.0.1376: accessing invalid memory with put in Visual block mode (#22505)
Problem: Accessing invalid memory with put in Visual block mode.
Solution: Adjust the cursor column if needed.
1c73b65229
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
b48ad28a3e
commit
446c353a50
@ -3346,7 +3346,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
ptr += yanklen;
|
ptr += yanklen;
|
||||||
|
|
||||||
// insert block's trailing spaces only if there's text behind
|
// insert block's trailing spaces only if there's text behind
|
||||||
if ((j < count - 1 || !shortline) && spaces) {
|
if ((j < count - 1 || !shortline) && spaces > 0) {
|
||||||
memset(ptr, ' ', (size_t)spaces);
|
memset(ptr, ' ', (size_t)spaces);
|
||||||
ptr += spaces;
|
ptr += spaces;
|
||||||
} else {
|
} else {
|
||||||
@ -3685,6 +3685,15 @@ error:
|
|||||||
msgmore(nr_lines);
|
msgmore(nr_lines);
|
||||||
curwin->w_set_curswant = true;
|
curwin->w_set_curswant = true;
|
||||||
|
|
||||||
|
// Make sure the cursor is not after the NUL.
|
||||||
|
int len = (int)strlen(get_cursor_line_ptr());
|
||||||
|
if (curwin->w_cursor.col > len) {
|
||||||
|
if (cur_ve_flags == VE_ALL) {
|
||||||
|
curwin->w_cursor.coladd = curwin->w_cursor.col - len;
|
||||||
|
}
|
||||||
|
curwin->w_cursor.col = len;
|
||||||
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if (cmdmod.cmod_flags & CMOD_LOCKMARKS) {
|
if (cmdmod.cmod_flags & CMOD_LOCKMARKS) {
|
||||||
curbuf->b_op_start = orig_start;
|
curbuf->b_op_start = orig_start;
|
||||||
|
@ -235,5 +235,16 @@ func Test_put_visual_mode()
|
|||||||
set selection&
|
set selection&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_put_visual_block_mode()
|
||||||
|
enew
|
||||||
|
exe "norm 0R\<CR>\<C-C>V"
|
||||||
|
sil exe "norm \<C-V>c \<MiddleDrag>"
|
||||||
|
set ve=all
|
||||||
|
sil norm vz=p
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
set ve=
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Loading…
Reference in New Issue
Block a user