Karsten Hopp 756952
To: vim_dev@googlegroups.com
Karsten Hopp 756952
Subject: Patch 7.3.365
Karsten Hopp 756952
Fcc: outbox
Karsten Hopp 756952
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 756952
Mime-Version: 1.0
Karsten Hopp 756952
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 756952
Content-Transfer-Encoding: 8bit
Karsten Hopp 756952
------------
Karsten Hopp 756952
Karsten Hopp 756952
Patch 7.3.365
Karsten Hopp 756952
Problem:    Crash when using a large Unicode character in a file that has
Karsten Hopp 756952
	    syntax highlighting. (ngollan)
Karsten Hopp 756952
Solution:   Check for going past the end of the utf tables. (Dominique Pelle)
Karsten Hopp 756952
Files:	    src/mbyte.c
Karsten Hopp 756952
Karsten Hopp 756952
Karsten Hopp 756952
*** ../vim-7.3.364/src/mbyte.c	2011-08-10 13:21:30.000000000 +0200
Karsten Hopp 756952
--- src/mbyte.c	2011-12-08 15:09:13.000000000 +0100
Karsten Hopp 756952
***************
Karsten Hopp 756952
*** 2764,2782 ****
Karsten Hopp 756952
      int			tableSize;
Karsten Hopp 756952
  {
Karsten Hopp 756952
      int start, mid, end; /* indices into table */
Karsten Hopp 756952
  
Karsten Hopp 756952
      start = 0;
Karsten Hopp 756952
!     end = tableSize / sizeof(convertStruct);
Karsten Hopp 756952
      while (start < end)
Karsten Hopp 756952
      {
Karsten Hopp 756952
  	/* need to search further */
Karsten Hopp 756952
! 	mid = (end + start) /2;
Karsten Hopp 756952
  	if (table[mid].rangeEnd < a)
Karsten Hopp 756952
  	    start = mid + 1;
Karsten Hopp 756952
  	else
Karsten Hopp 756952
  	    end = mid;
Karsten Hopp 756952
      }
Karsten Hopp 756952
!     if (table[start].rangeStart <= a && a <= table[start].rangeEnd
Karsten Hopp 756952
  	    && (a - table[start].rangeStart) % table[start].step == 0)
Karsten Hopp 756952
  	return (a + table[start].offset);
Karsten Hopp 756952
      else
Karsten Hopp 756952
--- 2764,2785 ----
Karsten Hopp 756952
      int			tableSize;
Karsten Hopp 756952
  {
Karsten Hopp 756952
      int start, mid, end; /* indices into table */
Karsten Hopp 756952
+     int entries = tableSize / sizeof(convertStruct);
Karsten Hopp 756952
  
Karsten Hopp 756952
      start = 0;
Karsten Hopp 756952
!     end = entries;
Karsten Hopp 756952
      while (start < end)
Karsten Hopp 756952
      {
Karsten Hopp 756952
  	/* need to search further */
Karsten Hopp 756952
! 	mid = (end + start) / 2;
Karsten Hopp 756952
  	if (table[mid].rangeEnd < a)
Karsten Hopp 756952
  	    start = mid + 1;
Karsten Hopp 756952
  	else
Karsten Hopp 756952
  	    end = mid;
Karsten Hopp 756952
      }
Karsten Hopp 756952
!     if (start < entries
Karsten Hopp 756952
! 	    && table[start].rangeStart <= a
Karsten Hopp 756952
! 	    && a <= table[start].rangeEnd
Karsten Hopp 756952
  	    && (a - table[start].rangeStart) % table[start].step == 0)
Karsten Hopp 756952
  	return (a + table[start].offset);
Karsten Hopp 756952
      else
Karsten Hopp 756952
***************
Karsten Hopp 756952
*** 2791,2797 ****
Karsten Hopp 756952
  utf_fold(a)
Karsten Hopp 756952
      int		a;
Karsten Hopp 756952
  {
Karsten Hopp 756952
!     return utf_convert(a, foldCase, sizeof(foldCase));
Karsten Hopp 756952
  }
Karsten Hopp 756952
  
Karsten Hopp 756952
  static convertStruct toLower[] =
Karsten Hopp 756952
--- 2794,2800 ----
Karsten Hopp 756952
  utf_fold(a)
Karsten Hopp 756952
      int		a;
Karsten Hopp 756952
  {
Karsten Hopp 756952
!     return utf_convert(a, foldCase, (int)sizeof(foldCase));
Karsten Hopp 756952
  }
Karsten Hopp 756952
  
Karsten Hopp 756952
  static convertStruct toLower[] =
Karsten Hopp 756952
***************
Karsten Hopp 756952
*** 3119,3125 ****
Karsten Hopp 756952
  	return TOUPPER_LOC(a);
Karsten Hopp 756952
  
Karsten Hopp 756952
      /* For any other characters use the above mapping table. */
Karsten Hopp 756952
!     return utf_convert(a, toUpper, sizeof(toUpper));
Karsten Hopp 756952
  }
Karsten Hopp 756952
  
Karsten Hopp 756952
      int
Karsten Hopp 756952
--- 3122,3128 ----
Karsten Hopp 756952
  	return TOUPPER_LOC(a);
Karsten Hopp 756952
  
Karsten Hopp 756952
      /* For any other characters use the above mapping table. */
Karsten Hopp 756952
!     return utf_convert(a, toUpper, (int)sizeof(toUpper));
Karsten Hopp 756952
  }
Karsten Hopp 756952
  
Karsten Hopp 756952
      int
Karsten Hopp 756952
***************
Karsten Hopp 756952
*** 3152,3158 ****
Karsten Hopp 756952
  	return TOLOWER_LOC(a);
Karsten Hopp 756952
  
Karsten Hopp 756952
      /* For any other characters use the above mapping table. */
Karsten Hopp 756952
!     return utf_convert(a, toLower, sizeof(toLower));
Karsten Hopp 756952
  }
Karsten Hopp 756952
  
Karsten Hopp 756952
      int
Karsten Hopp 756952
--- 3155,3161 ----
Karsten Hopp 756952
  	return TOLOWER_LOC(a);
Karsten Hopp 756952
  
Karsten Hopp 756952
      /* For any other characters use the above mapping table. */
Karsten Hopp 756952
!     return utf_convert(a, toLower, (int)sizeof(toLower));
Karsten Hopp 756952
  }
Karsten Hopp 756952
  
Karsten Hopp 756952
      int
Karsten Hopp 756952
*** ../vim-7.3.364/src/version.c	2011-12-01 20:59:16.000000000 +0100
Karsten Hopp 756952
--- src/version.c	2011-12-08 15:07:53.000000000 +0100
Karsten Hopp 756952
***************
Karsten Hopp 756952
*** 716,717 ****
Karsten Hopp 756952
--- 716,719 ----
Karsten Hopp 756952
  {   /* Add new patch number below this line */
Karsten Hopp 756952
+ /**/
Karsten Hopp 756952
+     365,
Karsten Hopp 756952
  /**/
Karsten Hopp 756952
Karsten Hopp 756952
-- 
Karsten Hopp 756952
Hear about the guy who played a blank tape at full blast?
Karsten Hopp 756952
The mime next door went nuts.
Karsten Hopp 756952
Karsten Hopp 756952
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 756952
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 756952
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 756952
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///