99b86a7
To: vim-dev@vim.org
99b86a7
Subject: patch 7.1.051
99b86a7
Fcc: outbox
99b86a7
From: Bram Moolenaar <Bram@moolenaar.net>
99b86a7
Mime-Version: 1.0
99b86a7
Content-Type: text/plain; charset=ISO-8859-1
99b86a7
Content-Transfer-Encoding: 8bit
99b86a7
------------
99b86a7
99b86a7
Patch 7.1.051
99b86a7
Problem:    Accessing uninitialized memory when finding spell suggestions.
99b86a7
Solution:   Don't try swapping characters at the end of a word.
99b86a7
Files:	    src/spell.c
99b86a7
99b86a7
99b86a7
*** ../vim-7.1.050/src/spell.c	Tue Jul 24 10:44:10 2007
99b86a7
--- src/spell.c	Sun Aug  5 16:59:48 2007
99b86a7
***************
99b86a7
*** 12182,12188 ****
99b86a7
  	    {
99b86a7
  		n = mb_cptr2len(p);
99b86a7
  		c = mb_ptr2char(p);
99b86a7
! 		if (!soundfold && !spell_iswordp(p + n, curbuf))
99b86a7
  		    c2 = c; /* don't swap non-word char */
99b86a7
  		else
99b86a7
  		    c2 = mb_ptr2char(p + n);
99b86a7
--- 12182,12190 ----
99b86a7
  	    {
99b86a7
  		n = mb_cptr2len(p);
99b86a7
  		c = mb_ptr2char(p);
99b86a7
! 		if (p[n] == NUL)
99b86a7
! 		    c2 = NUL;
99b86a7
! 		else if (!soundfold && !spell_iswordp(p + n, curbuf))
99b86a7
  		    c2 = c; /* don't swap non-word char */
99b86a7
  		else
99b86a7
  		    c2 = mb_ptr2char(p + n);
99b86a7
***************
99b86a7
*** 12190,12199 ****
99b86a7
  	    else
99b86a7
  #endif
99b86a7
  	    {
99b86a7
! 		if (!soundfold && !spell_iswordp(p + 1, curbuf))
99b86a7
  		    c2 = c; /* don't swap non-word char */
99b86a7
  		else
99b86a7
  		    c2 = p[1];
99b86a7
  	    }
99b86a7
  
99b86a7
  	    /* When characters are identical, swap won't do anything.
99b86a7
--- 12192,12210 ----
99b86a7
  	    else
99b86a7
  #endif
99b86a7
  	    {
99b86a7
! 		if (p[1] == NUL)
99b86a7
! 		    c2 = NUL;
99b86a7
! 		else if (!soundfold && !spell_iswordp(p + 1, curbuf))
99b86a7
  		    c2 = c; /* don't swap non-word char */
99b86a7
  		else
99b86a7
  		    c2 = p[1];
99b86a7
+ 	    }
99b86a7
+ 
99b86a7
+ 	    /* When the second character is NUL we can't swap. */
99b86a7
+ 	    if (c2 == NUL)
99b86a7
+ 	    {
99b86a7
+ 		sp->ts_state = STATE_REP_INI;
99b86a7
+ 		break;
99b86a7
  	    }
99b86a7
  
99b86a7
  	    /* When characters are identical, swap won't do anything.
99b86a7
*** ../vim-7.1.050/src/version.c	Sat Aug  4 12:14:04 2007
99b86a7
--- src/version.c	Sun Aug  5 18:31:09 2007
99b86a7
***************
99b86a7
*** 668,669 ****
99b86a7
--- 668,671 ----
99b86a7
  {   /* Add new patch number below this line */
99b86a7
+ /**/
99b86a7
+     51,
99b86a7
  /**/
99b86a7
99b86a7
-- 
99b86a7
From "know your smileys":
99b86a7
 8<}}	Glasses, big nose, beard
99b86a7
99b86a7
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
99b86a7
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
99b86a7
\\\        download, build and distribute -- http://www.A-A-P.org        ///
99b86a7
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///