Patch 8.2.4151

21 views
Skip to first unread message

Bram Moolenaar

unread,
Jan 20, 2022, 7:11:29 AM1/20/22
to vim...@googlegroups.com

Patch 8.2.4151
Problem: Reading beyond the end of a line.
Solution: For block insert only use the offset for correcting the length.
Files: src/ops.c, src/testdir/test_visual.vim


*** ../vim-8.2.4150/src/ops.c 2022-01-17 17:30:17.333810748 +0000
--- src/ops.c 2022-01-20 12:05:41.775100271 +0000
***************
*** 529,552 ****
}

if (has_mbyte && spaces > 0)
! {
! int off;

- // Avoid starting halfway a multi-byte character.
- if (b_insert)
- {
- off = (*mb_head_off)(oldp, oldp + offset + spaces);
- spaces -= off;
- count -= off;
- }
- else
- {
- // spaces fill the gap, the character that's at the edge moves
- // right
- off = (*mb_head_off)(oldp, oldp + offset);
- offset -= off;
- }
- }
if (spaces < 0) // can happen when the cursor was moved
spaces = 0;

--- 529,537 ----
}

if (has_mbyte && spaces > 0)
! // avoid copying part of a multi-byte character
! offset -= (*mb_head_off)(oldp, oldp + offset);

if (spaces < 0) // can happen when the cursor was moved
spaces = 0;

*** ../vim-8.2.4150/src/testdir/test_visual.vim 2022-01-17 17:52:18.107986971 +0000
--- src/testdir/test_visual.vim 2022-01-20 12:04:12.980940760 +0000
***************
*** 1309,1313 ****
--- 1309,1322 ----
call delete('XvisualReselect')
endfunc

+ func Test_visual_block_insert_round_off()
+ new
+ " The number of characters are tuned to fill a 4096 byte allocated block,
+ " so that valgrind reports going over the end.
+ call setline(1, ['xxxxx', repeat('0', 1350), "\t", repeat('x', 60)])
+ exe "normal gg0\<C-V>GI" .. repeat('0', 1320) .. "\<Esc>"
+ bwipe!
+ endfunc
+

" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.4150/src/version.c 2022-01-20 11:27:46.282545377 +0000
--- src/version.c 2022-01-20 12:07:31.400828147 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4151,
/**/

--
ARTHUR: Listen, old crone! Unless you tell us where we can buy a shrubbery,
my friend and I will ... we will say "Ni!"
CRONE: Do your worst!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@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 ///
Reply all
Reply to author
Forward
0 new messages