299eb4e
To: vim-dev@vim.org
299eb4e
Subject: Patch 7.2.268
299eb4e
Fcc: outbox
299eb4e
From: Bram Moolenaar <Bram@moolenaar.net>
299eb4e
Mime-Version: 1.0
299eb4e
Content-Type: text/plain; charset=UTF-8
299eb4e
Content-Transfer-Encoding: 8bit
299eb4e
------------
299eb4e
299eb4e
Patch 7.2.268
299eb4e
Problem:    Crash when using Python to set cursor beyond end of line.
299eb4e
	    (winterTTr)
299eb4e
Solution:   Check the column to be valid.
299eb4e
Files:	    src/if_python.c
299eb4e
299eb4e
299eb4e
*** ../vim-7.2.267/src/if_python.c	2009-07-09 20:06:30.000000000 +0200
299eb4e
--- src/if_python.c	2009-10-10 14:49:10.000000000 +0200
299eb4e
***************
299eb4e
*** 2058,2063 ****
299eb4e
--- 2058,2064 ----
299eb4e
      {
299eb4e
  	long lnum;
299eb4e
  	long col;
299eb4e
+ 	long len;
299eb4e
  
299eb4e
  	if (!PyArg_Parse(val, "(ll)", &lnum, &col))
299eb4e
  	    return -1;
299eb4e
***************
299eb4e
*** 2072,2081 ****
299eb4e
  	if (VimErrorCheck())
299eb4e
  	    return -1;
299eb4e
  
299eb4e
! 	/* NO CHECK ON COLUMN - SEEMS NOT TO MATTER */
299eb4e
  
299eb4e
  	this->win->w_cursor.lnum = lnum;
299eb4e
  	this->win->w_cursor.col = col;
299eb4e
  	update_screen(VALID);
299eb4e
  
299eb4e
  	return 0;
299eb4e
--- 2073,2088 ----
299eb4e
  	if (VimErrorCheck())
299eb4e
  	    return -1;
299eb4e
  
299eb4e
! 	/* When column is out of range silently correct it. */
299eb4e
! 	len = STRLEN(ml_get_buf(this->win->w_buffer, lnum, FALSE));
299eb4e
! 	if (col > len)
299eb4e
! 	    col = len;
299eb4e
  
299eb4e
  	this->win->w_cursor.lnum = lnum;
299eb4e
  	this->win->w_cursor.col = col;
299eb4e
+ #ifdef FEAT_VIRTUALEDIT
299eb4e
+ 	this->win->w_cursor.coladd = 0;
299eb4e
+ #endif
299eb4e
  	update_screen(VALID);
299eb4e
  
299eb4e
  	return 0;
299eb4e
*** ../vim-7.2.267/src/version.c	2009-10-07 16:19:52.000000000 +0200
299eb4e
--- src/version.c	2009-11-03 11:42:08.000000000 +0100
299eb4e
***************
299eb4e
*** 678,679 ****
299eb4e
--- 678,681 ----
299eb4e
  {   /* Add new patch number below this line */
299eb4e
+ /**/
299eb4e
+     268,
299eb4e
  /**/
299eb4e
299eb4e
-- 
299eb4e
VOICE OVER: As the horrendous Black Beast lunged forward, escape for Arthur
299eb4e
            and his knights seemed hopeless,  when, suddenly ... the animator
299eb4e
            suffered a fatal heart attack.
299eb4e
ANIMATOR:   Aaaaagh!
299eb4e
VOICE OVER: The cartoon peril was no more ... The Quest for Holy Grail could
299eb4e
            continue.
299eb4e
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
299eb4e
299eb4e
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
299eb4e
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
299eb4e
\\\        download, build and distribute -- http://www.A-A-P.org        ///
299eb4e
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///