0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.2.3494: illegal memory access in utf_head_off

Problem:    Illegal memory access in utf_head_off.
Solution:   Check cursor position when reselecting the Visual area.
            (closes #8963)
This commit is contained in:
Bram Moolenaar
2021-10-11 15:40:43 +01:00
parent cddd5ac911
commit b07626d4af
3 changed files with 23 additions and 2 deletions

View File

@@ -5671,8 +5671,7 @@ nv_visual(cmdarg_T *cap)
{ {
curwin->w_cursor.lnum += curwin->w_cursor.lnum +=
resel_VIsual_line_count * cap->count0 - 1; resel_VIsual_line_count * cap->count0 - 1;
if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) check_cursor();
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
} }
VIsual_mode = resel_VIsual_mode; VIsual_mode = resel_VIsual_mode;
if (VIsual_mode == 'v') if (VIsual_mode == 'v')

View File

@@ -1265,5 +1265,25 @@ func Test_visual_block_with_virtualedit()
call delete('XTest_block') call delete('XTest_block')
endfunc endfunc
func Test_visual_reselect_with_count()
" this was causing an illegal memory access
let lines =<< trim END
:
r<sfile>
exe "%norm e3\<c-v>kr\t"
:
:
END
call writefile(lines, 'XvisualReselect')
source XvisualReselect
bwipe!
call delete('XvisualReselect')
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -757,6 +757,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3494,
/**/ /**/
3493, 3493,
/**/ /**/