Patch 8.2.3949
Problem:    Using freed memory with /\%V.
Solution:   Get the line again after getvvcol().
Files:      src/regexp.c, src/testdir/test_regexp_latin.vim


*** ../vim-8.2.3948/src/regexp.c        2021-12-13 14:26:40.992627753 +0000
--- src/regexp.c        2021-12-30 14:46:55.533679163 +0000
***************
*** 1310,1318 ****
      if (lnum < top.lnum || lnum > bot.lnum)
        return FALSE;
  
      if (mode == 'v')
      {
-       col = (colnr_T)(rex.input - rex.line);
        if ((lnum == top.lnum && col < top.col)
                || (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e')))
            return FALSE;
--- 1310,1318 ----
      if (lnum < top.lnum || lnum > bot.lnum)
        return FALSE;
  
+     col = (colnr_T)(rex.input - rex.line);
      if (mode == 'v')
      {
        if ((lnum == top.lnum && col < top.col)
                || (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e')))
            return FALSE;
***************
*** 1327,1333 ****
            end = end2;
        if (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL)
            end = MAXCOL;
!       cols = win_linetabsize(wp, rex.line, (colnr_T)(rex.input - rex.line));
        if (cols < start || cols > end - (*p_sel == 'e'))
            return FALSE;
      }
--- 1327,1338 ----
            end = end2;
        if (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL)
            end = MAXCOL;
! 
!       // getvvcol() flushes rex.line, need to get it again
!       rex.line = reg_getline(rex.lnum);
!       rex.input = rex.line + col;
! 
!       cols = win_linetabsize(wp, rex.line, col);
        if (cols < start || cols > end - (*p_sel == 'e'))
            return FALSE;
      }
*** ../vim-8.2.3948/src/testdir/test_regexp_latin.vim   2021-11-17 
18:22:52.980044225 +0000
--- src/testdir/test_regexp_latin.vim   2021-12-30 14:43:13.617998398 +0000
***************
*** 1045,1048 ****
--- 1045,1056 ----
    bwipe!
  endfunc
  
+ func Test_using_visual_position()
+   " this was using freed memory
+   new
+   exe "norm 0o\<Esc>\<C-V>k\<C-X>o0"
+   /\%V
+   bwipe!
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.3948/src/version.c       2021-12-30 13:59:17.038036582 +0000
--- src/version.c       2021-12-30 14:48:16.797563418 +0000
***************
*** 751,752 ****
--- 751,754 ----
  {   /* Add new patch number below this line */
+ /**/
+     3949,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
154. You fondle your mouse.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211230145115.A32831C0A5B%40moolenaar.net.

Raspunde prin e-mail lui