To: vim_dev@googlegroups.com Subject: Patch 9.0.1376 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1376 Problem: Accessing invalid memory with put in Visual block mode. Solution: Adjust the cursor column if needed. Files: src/register.c, src/testdir/test_put.vim *** ../vim-9.0.1375/src/register.c 2023-02-21 14:27:34.524360386 +0000 --- src/register.c 2023-03-03 21:10:07.289422428 +0000 *************** *** 1928,1934 **** ptr += yanklen; // insert block's trailing spaces only if there's text behind ! if ((j < count - 1 || !shortline) && spaces) { vim_memset(ptr, ' ', (size_t)spaces); ptr += spaces; --- 1928,1934 ---- ptr += yanklen; // insert block's trailing spaces only if there's text behind ! if ((j < count - 1 || !shortline) && spaces > 0) { vim_memset(ptr, ' ', (size_t)spaces); ptr += spaces; *************** *** 2284,2289 **** --- 2284,2298 ---- msgmore(nr_lines); curwin->w_set_curswant = TRUE; + // Make sure the cursor is not after the NUL. + int len = (int)STRLEN(ml_get_curline()); + 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: if (cmdmod.cmod_flags & CMOD_LOCKMARKS) { *** ../vim-9.0.1375/src/testdir/test_put.vim 2022-06-30 12:30:13.823485781 +0100 --- src/testdir/test_put.vim 2023-03-03 21:08:53.833435043 +0000 *************** *** 231,235 **** --- 231,246 ---- set selection& endfunc + func Test_put_visual_block_mode() + enew + exe "norm 0R\\V" + sil exe "norm \c \" + set ve=all + sil norm vz=p + + bwipe! + set ve= + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.1375/src/version.c 2023-03-03 15:05:26.784832737 +0000 --- src/version.c 2023-03-03 21:03:40.337575383 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1376, /**/ -- hundred-and-one symptoms of being an internet addict: 219. Your spouse has his or her lawyer deliver the divorce papers... via e-mail. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///