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