Karsten Hopp 253468
To: vim-dev@vim.org
Karsten Hopp 253468
Subject: patch 7.1.054
Karsten Hopp 253468
Fcc: outbox
Karsten Hopp 253468
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 253468
Mime-Version: 1.0
Karsten Hopp 253468
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 253468
Content-Transfer-Encoding: 8bit
Karsten Hopp 253468
------------
Karsten Hopp 253468
Karsten Hopp 253468
Patch 7.1.054
Karsten Hopp 253468
Problem:    Accessing uninitialized memory when displaying the fold column.
Karsten Hopp 253468
Solution:   Add a NUL to the extra array. (Dominique Pelle).  Also do this in
Karsten Hopp 253468
	    a couple of other situations.
Karsten Hopp 253468
Files:	    src/screen.c
Karsten Hopp 253468
Karsten Hopp 253468
Karsten Hopp 253468
*** ../vim-7.1.053/src/screen.c	Mon Jul 30 21:59:50 2007
Karsten Hopp 253468
--- src/screen.c	Sun Aug  5 16:10:53 2007
Karsten Hopp 253468
***************
Karsten Hopp 253468
*** 2555,2561 ****
Karsten Hopp 253468
  
Karsten Hopp 253468
      char_u	extra[18];		/* "%ld" and 'fdc' must fit in here */
Karsten Hopp 253468
      int		n_extra = 0;		/* number of extra chars */
Karsten Hopp 253468
!     char_u	*p_extra = NULL;	/* string of extra chars */
Karsten Hopp 253468
      int		c_extra = NUL;		/* extra chars, all the same */
Karsten Hopp 253468
      int		extra_attr = 0;		/* attributes when n_extra != 0 */
Karsten Hopp 253468
      static char_u *at_end_str = (char_u *)""; /* used for p_extra when
Karsten Hopp 253468
--- 2555,2561 ----
Karsten Hopp 253468
  
Karsten Hopp 253468
      char_u	extra[18];		/* "%ld" and 'fdc' must fit in here */
Karsten Hopp 253468
      int		n_extra = 0;		/* number of extra chars */
Karsten Hopp 253468
!     char_u	*p_extra = NULL;	/* string of extra chars, plus NUL */
Karsten Hopp 253468
      int		c_extra = NUL;		/* extra chars, all the same */
Karsten Hopp 253468
      int		extra_attr = 0;		/* attributes when n_extra != 0 */
Karsten Hopp 253468
      static char_u *at_end_str = (char_u *)""; /* used for p_extra when
Karsten Hopp 253468
***************
Karsten Hopp 253468
*** 3189,3198 ****
Karsten Hopp 253468
  		if (cmdwin_type != 0 && wp == curwin)
Karsten Hopp 253468
  		{
Karsten Hopp 253468
  		    /* Draw the cmdline character. */
Karsten Hopp 253468
- 		    *extra = cmdwin_type;
Karsten Hopp 253468
  		    n_extra = 1;
Karsten Hopp 253468
! 		    p_extra = extra;
Karsten Hopp 253468
! 		    c_extra = NUL;
Karsten Hopp 253468
  		    char_attr = hl_attr(HLF_AT);
Karsten Hopp 253468
  		}
Karsten Hopp 253468
  	    }
Karsten Hopp 253468
--- 3189,3196 ----
Karsten Hopp 253468
  		if (cmdwin_type != 0 && wp == curwin)
Karsten Hopp 253468
  		{
Karsten Hopp 253468
  		    /* Draw the cmdline character. */
Karsten Hopp 253468
  		    n_extra = 1;
Karsten Hopp 253468
! 		    c_extra = cmdwin_type;
Karsten Hopp 253468
  		    char_attr = hl_attr(HLF_AT);
Karsten Hopp 253468
  		}
Karsten Hopp 253468
  	    }
Karsten Hopp 253468
***************
Karsten Hopp 253468
*** 3208,3213 ****
Karsten Hopp 253468
--- 3206,3212 ----
Karsten Hopp 253468
  		    fill_foldcolumn(extra, wp, FALSE, lnum);
Karsten Hopp 253468
  		    n_extra = wp->w_p_fdc;
Karsten Hopp 253468
  		    p_extra = extra;
Karsten Hopp 253468
+ 		    p_extra[n_extra] = NUL;
Karsten Hopp 253468
  		    c_extra = NUL;
Karsten Hopp 253468
  		    char_attr = hl_attr(HLF_FC);
Karsten Hopp 253468
  		}
Karsten Hopp 253468
***************
Karsten Hopp 253468
*** 3550,3558 ****
Karsten Hopp 253468
  	 * Get the next character to put on the screen.
Karsten Hopp 253468
  	 */
Karsten Hopp 253468
  	/*
Karsten Hopp 253468
! 	 * The 'extra' array contains the extra stuff that is inserted to
Karsten Hopp 253468
! 	 * represent special characters (non-printable stuff).  When all
Karsten Hopp 253468
! 	 * characters are the same, c_extra is used.
Karsten Hopp 253468
  	 * For the '$' of the 'list' option, n_extra == 1, p_extra == "".
Karsten Hopp 253468
  	 */
Karsten Hopp 253468
  	if (n_extra > 0)
Karsten Hopp 253468
--- 3549,3559 ----
Karsten Hopp 253468
  	 * Get the next character to put on the screen.
Karsten Hopp 253468
  	 */
Karsten Hopp 253468
  	/*
Karsten Hopp 253468
! 	 * The "p_extra" points to the extra stuff that is inserted to
Karsten Hopp 253468
! 	 * represent special characters (non-printable stuff) and other
Karsten Hopp 253468
! 	 * things.  When all characters are the same, c_extra is used.
Karsten Hopp 253468
! 	 * "p_extra" must end in a NUL to avoid mb_ptr2len() reads past
Karsten Hopp 253468
! 	 * "p_extra[n_extra]".
Karsten Hopp 253468
  	 * For the '$' of the 'list' option, n_extra == 1, p_extra == "".
Karsten Hopp 253468
  	 */
Karsten Hopp 253468
  	if (n_extra > 0)
Karsten Hopp 253468
***************
Karsten Hopp 253468
*** 3808,3817 ****
Karsten Hopp 253468
  		 * a '<' in the first column. */
Karsten Hopp 253468
  		if (n_skip > 0 && mb_l > 1)
Karsten Hopp 253468
  		{
Karsten Hopp 253468
- 		    extra[0] = '<';
Karsten Hopp 253468
- 		    p_extra = extra;
Karsten Hopp 253468
  		    n_extra = 1;
Karsten Hopp 253468
! 		    c_extra = NUL;
Karsten Hopp 253468
  		    c = ' ';
Karsten Hopp 253468
  		    if (area_attr == 0 && search_attr == 0)
Karsten Hopp 253468
  		    {
Karsten Hopp 253468
--- 3809,3816 ----
Karsten Hopp 253468
  		 * a '<' in the first column. */
Karsten Hopp 253468
  		if (n_skip > 0 && mb_l > 1)
Karsten Hopp 253468
  		{
Karsten Hopp 253468
  		    n_extra = 1;
Karsten Hopp 253468
! 		    c_extra = '<';
Karsten Hopp 253468
  		    c = ' ';
Karsten Hopp 253468
  		    if (area_attr == 0 && search_attr == 0)
Karsten Hopp 253468
  		    {
Karsten Hopp 253468
***************
Karsten Hopp 253468
*** 6204,6211 ****
Karsten Hopp 253468
  	return;
Karsten Hopp 253468
  
Karsten Hopp 253468
      off = LineOffset[row] + col;
Karsten Hopp 253468
!     while (*ptr != NUL && col < screen_Columns
Karsten Hopp 253468
! 				      && (len < 0 || (int)(ptr - text) < len))
Karsten Hopp 253468
      {
Karsten Hopp 253468
  	c = *ptr;
Karsten Hopp 253468
  #ifdef FEAT_MBYTE
Karsten Hopp 253468
--- 6203,6211 ----
Karsten Hopp 253468
  	return;
Karsten Hopp 253468
  
Karsten Hopp 253468
      off = LineOffset[row] + col;
Karsten Hopp 253468
!     while (col < screen_Columns
Karsten Hopp 253468
! 	    && (len < 0 || (int)(ptr - text) < len)
Karsten Hopp 253468
! 	    && *ptr != NUL)
Karsten Hopp 253468
      {
Karsten Hopp 253468
  	c = *ptr;
Karsten Hopp 253468
  #ifdef FEAT_MBYTE
Karsten Hopp 253468
*** ../vim-7.1.053/src/version.c	Sun Aug  5 19:20:04 2007
Karsten Hopp 253468
--- src/version.c	Sun Aug  5 20:07:47 2007
Karsten Hopp 253468
***************
Karsten Hopp 253468
*** 668,669 ****
Karsten Hopp 253468
--- 668,671 ----
Karsten Hopp 253468
  {   /* Add new patch number below this line */
Karsten Hopp 253468
+ /**/
Karsten Hopp 253468
+     54,
Karsten Hopp 253468
  /**/
Karsten Hopp 253468
Karsten Hopp 253468
-- 
Karsten Hopp 253468
From "know your smileys":
Karsten Hopp 253468
 +<(:-) The Pope
Karsten Hopp 253468
Karsten Hopp 253468
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 253468
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 253468
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 253468
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///