Karsten Hopp 90e38f
To: vim-dev@vim.org
Karsten Hopp 90e38f
Subject: Patch 7.2.439
Karsten Hopp 90e38f
Fcc: outbox
Karsten Hopp 90e38f
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 90e38f
Mime-Version: 1.0
Karsten Hopp 90e38f
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 90e38f
Content-Transfer-Encoding: 8bit
Karsten Hopp 90e38f
------------
Karsten Hopp 90e38f
Karsten Hopp 90e38f
Patch 7.2.439
Karsten Hopp 90e38f
Problem:    Invalid memory access when doing thesaurus completion and
Karsten Hopp 90e38f
	    'infercase' is set.
Karsten Hopp 90e38f
Solution:   Use the minimal length of completed word and replacement.
Karsten Hopp 90e38f
	    (Dominique Pelle)
Karsten Hopp 90e38f
Files:	    src/edit.c
Karsten Hopp 90e38f
Karsten Hopp 90e38f
Karsten Hopp 90e38f
*** ../vim-7.2.438/src/edit.c	2010-03-10 14:15:28.000000000 +0100
Karsten Hopp 90e38f
--- src/edit.c	2010-05-28 21:20:29.000000000 +0200
Karsten Hopp 90e38f
***************
Karsten Hopp 90e38f
*** 2164,2169 ****
Karsten Hopp 90e38f
--- 2164,2170 ----
Karsten Hopp 90e38f
      int		i, c;
Karsten Hopp 90e38f
      int		actual_len;		/* Take multi-byte characters */
Karsten Hopp 90e38f
      int		actual_compl_length;	/* into account. */
Karsten Hopp 90e38f
+     int		min_len;
Karsten Hopp 90e38f
      int		*wca;			/* Wide character array. */
Karsten Hopp 90e38f
      int		has_lower = FALSE;
Karsten Hopp 90e38f
      int		was_letter = FALSE;
Karsten Hopp 90e38f
***************
Karsten Hopp 90e38f
*** 2204,2209 ****
Karsten Hopp 90e38f
--- 2205,2215 ----
Karsten Hopp 90e38f
  #endif
Karsten Hopp 90e38f
  	    actual_compl_length = compl_length;
Karsten Hopp 90e38f
  
Karsten Hopp 90e38f
+ 	/* "actual_len" may be smaller than "actual_compl_length" when using
Karsten Hopp 90e38f
+ 	 * thesaurus, only use the minimum when comparing. */
Karsten Hopp 90e38f
+ 	min_len = actual_len < actual_compl_length
Karsten Hopp 90e38f
+ 					   ? actual_len : actual_compl_length;
Karsten Hopp 90e38f
+ 
Karsten Hopp 90e38f
  	/* Allocate wide character array for the completion and fill it. */
Karsten Hopp 90e38f
  	wca = (int *)alloc((unsigned)(actual_len * sizeof(int)));
Karsten Hopp 90e38f
  	if (wca != NULL)
Karsten Hopp 90e38f
***************
Karsten Hopp 90e38f
*** 2219,2225 ****
Karsten Hopp 90e38f
  
Karsten Hopp 90e38f
  	    /* Rule 1: Were any chars converted to lower? */
Karsten Hopp 90e38f
  	    p = compl_orig_text;
Karsten Hopp 90e38f
! 	    for (i = 0; i < actual_compl_length; ++i)
Karsten Hopp 90e38f
  	    {
Karsten Hopp 90e38f
  #ifdef FEAT_MBYTE
Karsten Hopp 90e38f
  		if (has_mbyte)
Karsten Hopp 90e38f
--- 2225,2231 ----
Karsten Hopp 90e38f
  
Karsten Hopp 90e38f
  	    /* Rule 1: Were any chars converted to lower? */
Karsten Hopp 90e38f
  	    p = compl_orig_text;
Karsten Hopp 90e38f
! 	    for (i = 0; i < min_len; ++i)
Karsten Hopp 90e38f
  	    {
Karsten Hopp 90e38f
  #ifdef FEAT_MBYTE
Karsten Hopp 90e38f
  		if (has_mbyte)
Karsten Hopp 90e38f
***************
Karsten Hopp 90e38f
*** 2247,2253 ****
Karsten Hopp 90e38f
  	    if (!has_lower)
Karsten Hopp 90e38f
  	    {
Karsten Hopp 90e38f
  		p = compl_orig_text;
Karsten Hopp 90e38f
! 		for (i = 0; i < actual_compl_length; ++i)
Karsten Hopp 90e38f
  		{
Karsten Hopp 90e38f
  #ifdef FEAT_MBYTE
Karsten Hopp 90e38f
  		    if (has_mbyte)
Karsten Hopp 90e38f
--- 2253,2259 ----
Karsten Hopp 90e38f
  	    if (!has_lower)
Karsten Hopp 90e38f
  	    {
Karsten Hopp 90e38f
  		p = compl_orig_text;
Karsten Hopp 90e38f
! 		for (i = 0; i < min_len; ++i)
Karsten Hopp 90e38f
  		{
Karsten Hopp 90e38f
  #ifdef FEAT_MBYTE
Karsten Hopp 90e38f
  		    if (has_mbyte)
Karsten Hopp 90e38f
***************
Karsten Hopp 90e38f
*** 2268,2274 ****
Karsten Hopp 90e38f
  
Karsten Hopp 90e38f
  	    /* Copy the original case of the part we typed. */
Karsten Hopp 90e38f
  	    p = compl_orig_text;
Karsten Hopp 90e38f
! 	    for (i = 0; i < actual_compl_length; ++i)
Karsten Hopp 90e38f
  	    {
Karsten Hopp 90e38f
  #ifdef FEAT_MBYTE
Karsten Hopp 90e38f
  		if (has_mbyte)
Karsten Hopp 90e38f
--- 2274,2280 ----
Karsten Hopp 90e38f
  
Karsten Hopp 90e38f
  	    /* Copy the original case of the part we typed. */
Karsten Hopp 90e38f
  	    p = compl_orig_text;
Karsten Hopp 90e38f
! 	    for (i = 0; i < min_len; ++i)
Karsten Hopp 90e38f
  	    {
Karsten Hopp 90e38f
  #ifdef FEAT_MBYTE
Karsten Hopp 90e38f
  		if (has_mbyte)
Karsten Hopp 90e38f
*** ../vim-7.2.438/src/version.c	2010-05-25 21:37:12.000000000 +0200
Karsten Hopp 90e38f
--- src/version.c	2010-05-28 21:30:53.000000000 +0200
Karsten Hopp 90e38f
***************
Karsten Hopp 90e38f
*** 683,684 ****
Karsten Hopp 90e38f
--- 683,686 ----
Karsten Hopp 90e38f
  {   /* Add new patch number below this line */
Karsten Hopp 90e38f
+ /**/
Karsten Hopp 90e38f
+     439,
Karsten Hopp 90e38f
  /**/
Karsten Hopp 90e38f
Karsten Hopp 90e38f
-- 
Karsten Hopp 90e38f
Corduroy pillows: They're making headlines!
Karsten Hopp 90e38f
Karsten Hopp 90e38f
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 90e38f
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 90e38f
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 90e38f
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///