]> granicus.if.org Git - vim/commitdiff
patch 8.2.3494: illegal memory access in utf_head_off v8.2.3494
authorBram Moolenaar <Bram@vim.org>
Mon, 11 Oct 2021 14:40:43 +0000 (15:40 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 11 Oct 2021 14:40:43 +0000 (15:40 +0100)
Problem:    Illegal memory access in utf_head_off.
Solution:   Check cursor position when reselecting the Visual area.
            (closes #8963)

src/normal.c
src/testdir/test_visual.vim
src/version.c

index 8a4e778bcbfb371b2fe601bd13d795c972c83c6d..9cc2ea92489904dd0572b39662136943d554cbae 100644 (file)
@@ -5671,8 +5671,7 @@ nv_visual(cmdarg_T *cap)
            {
                curwin->w_cursor.lnum +=
                                    resel_VIsual_line_count * cap->count0 - 1;
-               if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
-                   curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
+               check_cursor();
            }
            VIsual_mode = resel_VIsual_mode;
            if (VIsual_mode == 'v')
index 10929519b4057da11483317a7607c42b8cedb97d..20eb4b43e8e8854c3bac2089ac4d7da3eb772c6b 100644 (file)
@@ -1265,5 +1265,25 @@ func Test_visual_block_with_virtualedit()
   call delete('XTest_block')
 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
index ce1939b0f715c1af9c0dcf7f841b68eebfdf2c9f..f5c8d76a51b2a248e6846fba07873af830c23f45 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3494,
 /**/
     3493,
 /**/