2102f06
To: vim-dev@vim.org
2102f06
Subject: Patch 7.2.279
2102f06
Fcc: outbox
2102f06
From: Bram Moolenaar <Bram@moolenaar.net>
2102f06
Mime-Version: 1.0
2102f06
Content-Type: text/plain; charset=UTF-8
2102f06
Content-Transfer-Encoding: 8bit
2102f06
------------
2102f06
2102f06
Patch 7.2.279
2102f06
Problem:    Invalid memory read with visual mode "r". (Dominique Pelle)
2102f06
Solution:   Make sure the cursor position is valid.  Don't check the cursor
2102f06
	    position but the position being used.  And make sure we get the
2102f06
	    right line.
2102f06
Files:	    src/misc2.c, src/ops.c
2102f06
2102f06
2102f06
*** ../vim-7.2.278/src/misc2.c	2009-05-16 21:06:36.000000000 +0200
2102f06
--- src/misc2.c	2009-11-03 16:43:10.000000000 +0100
2102f06
***************
2102f06
*** 156,162 ****
2102f06
  		    || ((ve_flags & VE_ONEMORE) && wcol < MAXCOL)
2102f06
  #endif
2102f06
  		    ;
2102f06
!     line = ml_get_curline();
2102f06
  
2102f06
      if (wcol >= MAXCOL)
2102f06
      {
2102f06
--- 156,162 ----
2102f06
  		    || ((ve_flags & VE_ONEMORE) && wcol < MAXCOL)
2102f06
  #endif
2102f06
  		    ;
2102f06
!     line = ml_get_buf(curbuf, pos->lnum, FALSE);
2102f06
  
2102f06
      if (wcol >= MAXCOL)
2102f06
      {
2102f06
***************
2102f06
*** 332,340 ****
2102f06
  #endif
2102f06
  
2102f06
  #ifdef FEAT_MBYTE
2102f06
!     /* prevent cursor from moving on the trail byte */
2102f06
      if (has_mbyte)
2102f06
! 	mb_adjust_cursor();
2102f06
  #endif
2102f06
  
2102f06
      if (col < wcol)
2102f06
--- 332,340 ----
2102f06
  #endif
2102f06
  
2102f06
  #ifdef FEAT_MBYTE
2102f06
!     /* prevent from moving onto a trail byte */
2102f06
      if (has_mbyte)
2102f06
! 	mb_adjustpos(pos);
2102f06
  #endif
2102f06
  
2102f06
      if (col < wcol)
2102f06
*** ../vim-7.2.278/src/ops.c	2009-09-30 15:15:33.000000000 +0200
2102f06
--- src/ops.c	2009-11-03 15:18:50.000000000 +0100
2102f06
***************
2102f06
*** 2020,2025 ****
2102f06
--- 2020,2026 ----
2102f06
  	bd.is_MAX = (curwin->w_curswant == MAXCOL);
2102f06
  	for ( ; curwin->w_cursor.lnum <= oap->end.lnum; ++curwin->w_cursor.lnum)
2102f06
  	{
2102f06
+ 	    curwin->w_cursor.col = 0;  /* make sure cursor position is valid */
2102f06
  	    block_prep(oap, &bd, curwin->w_cursor.lnum, TRUE);
2102f06
  	    if (bd.textlen == 0 && (!virtual_op || bd.is_MAX))
2102f06
  		continue;	    /* nothing to replace */
2102f06
***************
2102f06
*** 2035,2040 ****
2102f06
--- 2036,2042 ----
2102f06
  	    {
2102f06
  		pos_T vpos;
2102f06
  
2102f06
+ 		vpos.lnum = curwin->w_cursor.lnum;
2102f06
  		getvpos(&vpos, oap->start_vcol);
2102f06
  		bd.startspaces += vpos.coladd;
2102f06
  		n = bd.startspaces;
2102f06
***************
2102f06
*** 2693,2703 ****
2102f06
  			 * initial coladd offset as part of "startspaces" */
2102f06
  			if (bd.is_short)
2102f06
  			{
2102f06
! 			    linenr_T lnum = curwin->w_cursor.lnum;
2102f06
! 
2102f06
! 			    curwin->w_cursor.lnum = linenr;
2102f06
  			    (void)getvpos(&vpos, oap->start_vcol);
2102f06
- 			    curwin->w_cursor.lnum = lnum;
2102f06
  			}
2102f06
  			else
2102f06
  			    vpos.coladd = 0;
2102f06
--- 2695,2702 ----
2102f06
  			 * initial coladd offset as part of "startspaces" */
2102f06
  			if (bd.is_short)
2102f06
  			{
2102f06
! 			    vpos.lnum = linenr;
2102f06
  			    (void)getvpos(&vpos, oap->start_vcol);
2102f06
  			}
2102f06
  			else
2102f06
  			    vpos.coladd = 0;
2102f06
*** ../vim-7.2.278/src/version.c	2009-11-03 16:29:48.000000000 +0100
2102f06
--- src/version.c	2009-11-03 16:41:53.000000000 +0100
2102f06
***************
2102f06
*** 678,679 ****
2102f06
--- 678,681 ----
2102f06
  {   /* Add new patch number below this line */
2102f06
+ /**/
2102f06
+     279,
2102f06
  /**/
2102f06
2102f06
-- 
2102f06
BEDEVERE: How do you know so much about swallows?
2102f06
ARTHUR:   Well you have to know these things when you're a king, you know.
2102f06
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
2102f06
2102f06
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
2102f06
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
2102f06
\\\        download, build and distribute -- http://www.A-A-P.org        ///
2102f06
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///