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