[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vim-dev
Subject:    Patch 6.2.105
From:       Bram Moolenaar <Bram () moolenaar ! net>
Date:       2003-09-27 17:49:16
[Download RAW message or body]


Patch 6.2.105
Problem:    When the cursor is past the end of the line when calling
	    get_c_indent() a crash might occur.
Solution:   Don't look past the end of the line. (NJ Verenini)
Files:	    src/misc1.c


*** ../vim-6.2.104/src/misc1.c	Sat Sep 27 19:36:47 2003
--- src/misc1.c	Fri Sep 26 22:09:58 2003
***************
*** 5064,5076 ****
      }
  
      /* remember where the cursor was when we started */
- 
      cur_curpos = curwin->w_cursor;
  
!     /* get the current contents of the line.
       * This is required, because only the most recent line obtained with
       * ml_get is valid! */
- 
      linecopy = vim_strsave(ml_get(cur_curpos.lnum));
      if (linecopy == NULL)
  	return 0;
--- 5064,5074 ----
      }
  
      /* remember where the cursor was when we started */
      cur_curpos = curwin->w_cursor;
  
!     /* Get a copy of the current contents of the line.
       * This is required, because only the most recent line obtained with
       * ml_get is valid! */
      linecopy = vim_strsave(ml_get(cur_curpos.lnum));
      if (linecopy == NULL)
  	return 0;
***************
*** 5079,5086 ****
       * In insert mode and the cursor is on a ')' truncate the line at the
       * cursor position.  We don't want to line up with the matching '(' when
       * inserting new stuff.
       */
!     if ((State & INSERT) && linecopy[curwin->w_cursor.col] == ')')
  	linecopy[curwin->w_cursor.col] = NUL;
  
      theline = skipwhite(linecopy);
--- 5077,5088 ----
       * In insert mode and the cursor is on a ')' truncate the line at the
       * cursor position.  We don't want to line up with the matching '(' when
       * inserting new stuff.
+      * For unknown reasons the cursor might be past the end of the line, thus
+      * check for that.
       */
!     if ((State & INSERT)
! 	    && curwin->w_cursor.col < STRLEN(linecopy)
! 	    && linecopy[curwin->w_cursor.col] == ')')
  	linecopy[curwin->w_cursor.col] = NUL;
  
      theline = skipwhite(linecopy);
*** ../vim-6.2.104/src/version.c	Sat Sep 27 19:42:53 2003
--- src/version.c	Sat Sep 27 19:44:37 2003
***************
*** 632,633 ****
--- 638,641 ----
  {   /* Add new patch number below this line */
+ /**/
+     105,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
37. You start looking for hot HTML addresses in public restrooms.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///          Creator of Vim - Vi IMproved -- http://www.Vim.org          \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic