b70a649
To: vim-dev@vim.org
b70a649
Subject: Patch 7.2.406
b70a649
Fcc: outbox
b70a649
From: Bram Moolenaar <Bram@moolenaar.net>
b70a649
Mime-Version: 1.0
b70a649
Content-Type: text/plain; charset=UTF-8
b70a649
Content-Transfer-Encoding: 8bit
b70a649
------------
b70a649
b70a649
Patch 7.2.406
b70a649
Problem:    Patch 7.2.119 introduces uninit mem read. (Dominique Pelle)
b70a649
Solution:   Only used ScreeenLinesC when ScreeenLinesUC is not zero. (Yukihiro
b70a649
	    Nakadaira)  Also clear ScreeenLinesC when allocating.
b70a649
Files:	    src/screen.c
b70a649
b70a649
b70a649
*** ../vim-7.2.405/src/screen.c	2010-03-23 13:56:53.000000000 +0100
b70a649
--- src/screen.c	2010-03-23 15:26:44.000000000 +0100
b70a649
***************
b70a649
*** 25,34 ****
b70a649
   * one character which occupies two display cells.
b70a649
   * For UTF-8 a multi-byte character is converted to Unicode and stored in
b70a649
   * ScreenLinesUC[].  ScreenLines[] contains the first byte only.  For an ASCII
b70a649
!  * character without composing chars ScreenLinesUC[] will be 0.  When the
b70a649
!  * character occupies two display cells the next byte in ScreenLines[] is 0.
b70a649
   * ScreenLinesC[][] contain up to 'maxcombine' composing characters
b70a649
!  * (drawn on top of the first character).  They are 0 when not used.
b70a649
   * ScreenLines2[] is only used for euc-jp to store the second byte if the
b70a649
   * first byte is 0x8e (single-width character).
b70a649
   *
b70a649
--- 25,35 ----
b70a649
   * one character which occupies two display cells.
b70a649
   * For UTF-8 a multi-byte character is converted to Unicode and stored in
b70a649
   * ScreenLinesUC[].  ScreenLines[] contains the first byte only.  For an ASCII
b70a649
!  * character without composing chars ScreenLinesUC[] will be 0 and
b70a649
!  * ScreenLinesC[][] is not used.  When the character occupies two display
b70a649
!  * cells the next byte in ScreenLines[] is 0.
b70a649
   * ScreenLinesC[][] contain up to 'maxcombine' composing characters
b70a649
!  * (drawn on top of the first character).  There is 0 after the last one used.
b70a649
   * ScreenLines2[] is only used for euc-jp to store the second byte if the
b70a649
   * first byte is 0x8e (single-width character).
b70a649
   *
b70a649
***************
b70a649
*** 4893,4898 ****
b70a649
--- 4894,4900 ----
b70a649
  
b70a649
  /*
b70a649
   * Return if the composing characters at "off_from" and "off_to" differ.
b70a649
+  * Only to be used when ScreenLinesUC[off_from] != 0.
b70a649
   */
b70a649
      static int
b70a649
  comp_char_differs(off_from, off_to)
b70a649
***************
b70a649
*** 6281,6286 ****
b70a649
--- 6283,6289 ----
b70a649
  /*
b70a649
   * Return TRUE if composing characters for screen posn "off" differs from
b70a649
   * composing characters in "u8cc".
b70a649
+  * Only to be used when ScreenLinesUC[off] != 0.
b70a649
   */
b70a649
      static int
b70a649
  screen_comp_differs(off, u8cc)
b70a649
***************
b70a649
*** 6461,6468 ****
b70a649
  		    && c == 0x8e
b70a649
  		    && ScreenLines2[off] != ptr[1])
b70a649
  		|| (enc_utf8
b70a649
! 		    && (ScreenLinesUC[off] != (u8char_T)(c >= 0x80 ? u8c : 0)
b70a649
! 			|| screen_comp_differs(off, u8cc)))
b70a649
  #endif
b70a649
  		|| ScreenAttrs[off] != attr
b70a649
  		|| exmode_active;
b70a649
--- 6464,6473 ----
b70a649
  		    && c == 0x8e
b70a649
  		    && ScreenLines2[off] != ptr[1])
b70a649
  		|| (enc_utf8
b70a649
! 		    && (ScreenLinesUC[off] !=
b70a649
! 				(u8char_T)(c < 0x80 && u8cc[0] == 0 ? 0 : u8c)
b70a649
! 			|| (ScreenLinesUC[off] != 0
b70a649
! 					  && screen_comp_differs(off, u8cc))))
b70a649
  #endif
b70a649
  		|| ScreenAttrs[off] != attr
b70a649
  		|| exmode_active;
b70a649
***************
b70a649
*** 7542,7548 ****
b70a649
  	new_ScreenLinesUC = (u8char_T *)lalloc((long_u)(
b70a649
  			     (Rows + 1) * Columns * sizeof(u8char_T)), FALSE);
b70a649
  	for (i = 0; i < p_mco; ++i)
b70a649
! 	    new_ScreenLinesC[i] = (u8char_T *)lalloc((long_u)(
b70a649
  			     (Rows + 1) * Columns * sizeof(u8char_T)), FALSE);
b70a649
      }
b70a649
      if (enc_dbcs == DBCS_JPNU)
b70a649
--- 7547,7553 ----
b70a649
  	new_ScreenLinesUC = (u8char_T *)lalloc((long_u)(
b70a649
  			     (Rows + 1) * Columns * sizeof(u8char_T)), FALSE);
b70a649
  	for (i = 0; i < p_mco; ++i)
b70a649
! 	    new_ScreenLinesC[i] = (u8char_T *)lalloc_clear((long_u)(
b70a649
  			     (Rows + 1) * Columns * sizeof(u8char_T)), FALSE);
b70a649
      }
b70a649
      if (enc_dbcs == DBCS_JPNU)
b70a649
*** ../vim-7.2.405/src/version.c	2010-03-23 14:39:07.000000000 +0100
b70a649
--- src/version.c	2010-03-23 15:34:11.000000000 +0100
b70a649
***************
b70a649
*** 683,684 ****
b70a649
--- 683,686 ----
b70a649
  {   /* Add new patch number below this line */
b70a649
+ /**/
b70a649
+     406,
b70a649
  /**/
b70a649
b70a649
-- 
b70a649
VOICE OVER: As the horrendous Black Beast lunged forward, escape for Arthur
b70a649
            and his knights seemed hopeless,  when, suddenly ... the animator
b70a649
            suffered a fatal heart attack.
b70a649
ANIMATOR:   Aaaaagh!
b70a649
VOICE OVER: The cartoon peril was no more ... The Quest for Holy Grail could
b70a649
            continue.
b70a649
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
b70a649
b70a649
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
b70a649
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
b70a649
\\\        download, build and distribute -- http://www.A-A-P.org        ///
b70a649
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///