Karsten Hopp e67740
To: vim_dev@googlegroups.com
Karsten Hopp e67740
Subject: Patch 7.3.521
Karsten Hopp e67740
Fcc: outbox
Karsten Hopp e67740
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp e67740
Mime-Version: 1.0
Karsten Hopp e67740
Content-Type: text/plain; charset=UTF-8
Karsten Hopp e67740
Content-Transfer-Encoding: 8bit
Karsten Hopp e67740
------------
Karsten Hopp e67740
Karsten Hopp e67740
Patch 7.3.521
Karsten Hopp e67740
Problem:    Using "z=" on a multi-byte character may cause a crash.
Karsten Hopp e67740
Solution:   Don't use strlen() on an int pointer.
Karsten Hopp e67740
Files:	    src/spell.c
Karsten Hopp e67740
Karsten Hopp e67740
Karsten Hopp e67740
*** ../vim-7.3.520/src/spell.c	2012-01-10 22:26:12.000000000 +0100
Karsten Hopp e67740
--- src/spell.c	2012-05-18 18:01:58.000000000 +0200
Karsten Hopp e67740
***************
Karsten Hopp e67740
*** 14494,14506 ****
Karsten Hopp e67740
      int		p0 = -333;
Karsten Hopp e67740
      int		c0;
Karsten Hopp e67740
      int		did_white = FALSE;
Karsten Hopp e67740
  
Karsten Hopp e67740
      /*
Karsten Hopp e67740
       * Convert the multi-byte string to a wide-character string.
Karsten Hopp e67740
       * Remove accents, if wanted.  We actually remove all non-word characters.
Karsten Hopp e67740
       * But keep white space.
Karsten Hopp e67740
       */
Karsten Hopp e67740
!     n = 0;
Karsten Hopp e67740
      for (s = inword; *s != NUL; )
Karsten Hopp e67740
      {
Karsten Hopp e67740
  	t = s;
Karsten Hopp e67740
--- 14494,14508 ----
Karsten Hopp e67740
      int		p0 = -333;
Karsten Hopp e67740
      int		c0;
Karsten Hopp e67740
      int		did_white = FALSE;
Karsten Hopp e67740
+     int		wordlen;
Karsten Hopp e67740
+ 
Karsten Hopp e67740
  
Karsten Hopp e67740
      /*
Karsten Hopp e67740
       * Convert the multi-byte string to a wide-character string.
Karsten Hopp e67740
       * Remove accents, if wanted.  We actually remove all non-word characters.
Karsten Hopp e67740
       * But keep white space.
Karsten Hopp e67740
       */
Karsten Hopp e67740
!     wordlen = 0;
Karsten Hopp e67740
      for (s = inword; *s != NUL; )
Karsten Hopp e67740
      {
Karsten Hopp e67740
  	t = s;
Karsten Hopp e67740
***************
Karsten Hopp e67740
*** 14521,14532 ****
Karsten Hopp e67740
  		    continue;
Karsten Hopp e67740
  	    }
Karsten Hopp e67740
  	}
Karsten Hopp e67740
! 	word[n++] = c;
Karsten Hopp e67740
      }
Karsten Hopp e67740
!     word[n] = NUL;
Karsten Hopp e67740
  
Karsten Hopp e67740
      /*
Karsten Hopp e67740
!      * This comes from Aspell phonet.cpp.
Karsten Hopp e67740
       * Converted from C++ to C.  Added support for multi-byte chars.
Karsten Hopp e67740
       * Changed to keep spaces.
Karsten Hopp e67740
       */
Karsten Hopp e67740
--- 14523,14534 ----
Karsten Hopp e67740
  		    continue;
Karsten Hopp e67740
  	    }
Karsten Hopp e67740
  	}
Karsten Hopp e67740
! 	word[wordlen++] = c;
Karsten Hopp e67740
      }
Karsten Hopp e67740
!     word[wordlen] = NUL;
Karsten Hopp e67740
  
Karsten Hopp e67740
      /*
Karsten Hopp e67740
!      * This algorithm comes from Aspell phonet.cpp.
Karsten Hopp e67740
       * Converted from C++ to C.  Added support for multi-byte chars.
Karsten Hopp e67740
       * Changed to keep spaces.
Karsten Hopp e67740
       */
Karsten Hopp e67740
***************
Karsten Hopp e67740
*** 14711,14717 ****
Karsten Hopp e67740
  			    }
Karsten Hopp e67740
  			if (k > k0)
Karsten Hopp e67740
  			    mch_memmove(word + i + k0, word + i + k,
Karsten Hopp e67740
! 				    sizeof(int) * (STRLEN(word + i + k) + 1));
Karsten Hopp e67740
  
Karsten Hopp e67740
  			/* new "actual letter" */
Karsten Hopp e67740
  			c = word[i];
Karsten Hopp e67740
--- 14713,14719 ----
Karsten Hopp e67740
  			    }
Karsten Hopp e67740
  			if (k > k0)
Karsten Hopp e67740
  			    mch_memmove(word + i + k0, word + i + k,
Karsten Hopp e67740
! 				    sizeof(int) * (wordlen - (i + k) + 1));
Karsten Hopp e67740
  
Karsten Hopp e67740
  			/* new "actual letter" */
Karsten Hopp e67740
  			c = word[i];
Karsten Hopp e67740
***************
Karsten Hopp e67740
*** 14739,14745 ****
Karsten Hopp e67740
  			    if (c != NUL)
Karsten Hopp e67740
  				wres[reslen++] = c;
Karsten Hopp e67740
  			    mch_memmove(word, word + i + 1,
Karsten Hopp e67740
! 				    sizeof(int) * (STRLEN(word + i + 1) + 1));
Karsten Hopp e67740
  			    i = 0;
Karsten Hopp e67740
  			    z0 = 1;
Karsten Hopp e67740
  			}
Karsten Hopp e67740
--- 14741,14747 ----
Karsten Hopp e67740
  			    if (c != NUL)
Karsten Hopp e67740
  				wres[reslen++] = c;
Karsten Hopp e67740
  			    mch_memmove(word, word + i + 1,
Karsten Hopp e67740
! 				       sizeof(int) * (wordlen - (i + 1) + 1));
Karsten Hopp e67740
  			    i = 0;
Karsten Hopp e67740
  			    z0 = 1;
Karsten Hopp e67740
  			}
Karsten Hopp e67740
*** ../vim-7.3.520/src/version.c	2012-05-18 17:03:14.000000000 +0200
Karsten Hopp e67740
--- src/version.c	2012-05-18 18:06:29.000000000 +0200
Karsten Hopp e67740
***************
Karsten Hopp e67740
*** 716,717 ****
Karsten Hopp e67740
--- 716,719 ----
Karsten Hopp e67740
  {   /* Add new patch number below this line */
Karsten Hopp e67740
+ /**/
Karsten Hopp e67740
+     521,
Karsten Hopp e67740
  /**/
Karsten Hopp e67740
Karsten Hopp e67740
-- 
Karsten Hopp e67740
OLD WOMAN: King of the WHO?
Karsten Hopp e67740
ARTHUR:    The Britons.
Karsten Hopp e67740
OLD WOMAN: Who are the Britons?
Karsten Hopp e67740
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp e67740
Karsten Hopp e67740
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp e67740
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp e67740
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp e67740
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///