f14e283
To: vim-dev@vim.org
f14e283
Subject: Patch 7.1.251
f14e283
Fcc: outbox
f14e283
From: Bram Moolenaar <Bram@moolenaar.net>
f14e283
Mime-Version: 1.0
f14e283
Content-Type: text/plain; charset=ISO-8859-1
f14e283
Content-Transfer-Encoding: 8bit
f14e283
------------
f14e283
f14e283
Patch 7.1.251
f14e283
Problem:    Using freed memory when spell checking enabled.
f14e283
Solution:   Obtain the current line again after calling spell_move_to().
f14e283
	    (Dominique Pelle)
f14e283
Files:	    src/screen.c
f14e283
f14e283
f14e283
*** ../vim-7.1.250/src/screen.c	Sat Jan 19 15:55:51 2008
f14e283
--- src/screen.c	Wed Feb 13 21:45:38 2008
f14e283
***************
f14e283
*** 2644,2650 ****
f14e283
  #if defined(FEAT_SIGNS) || (defined(FEAT_QUICKFIX) && defined(FEAT_WINDOWS)) \
f14e283
  	|| defined(FEAT_SYN_HL) || defined(FEAT_DIFF)
f14e283
  # define LINE_ATTR
f14e283
!     int		line_attr = 0;		/* atrribute for the whole line */
f14e283
  #endif
f14e283
  #ifdef FEAT_SEARCH_EXTRA
f14e283
      matchitem_T *cur;			/* points to the match list */
f14e283
--- 2644,2650 ----
f14e283
  #if defined(FEAT_SIGNS) || (defined(FEAT_QUICKFIX) && defined(FEAT_WINDOWS)) \
f14e283
  	|| defined(FEAT_SYN_HL) || defined(FEAT_DIFF)
f14e283
  # define LINE_ATTR
f14e283
!     int		line_attr = 0;		/* attribute for the whole line */
f14e283
  #endif
f14e283
  #ifdef FEAT_SEARCH_EXTRA
f14e283
      matchitem_T *cur;			/* points to the match list */
f14e283
***************
f14e283
*** 3040,3057 ****
f14e283
  	if (has_spell)
f14e283
  	{
f14e283
  	    int		len;
f14e283
  	    hlf_T	spell_hlf = HLF_COUNT;
f14e283
  
f14e283
  	    pos = wp->w_cursor;
f14e283
  	    wp->w_cursor.lnum = lnum;
f14e283
! 	    wp->w_cursor.col = (colnr_T)(ptr - line);
f14e283
  	    len = spell_move_to(wp, FORWARD, TRUE, TRUE, &spell_hlf);
f14e283
  	    if (len == 0 || (int)wp->w_cursor.col > ptr - line)
f14e283
  	    {
f14e283
  		/* no bad word found at line start, don't check until end of a
f14e283
  		 * word */
f14e283
  		spell_hlf = HLF_COUNT;
f14e283
! 		word_end = (int)(spell_to_word_end(ptr, wp->w_buffer) - line + 1);
f14e283
  	    }
f14e283
  	    else
f14e283
  	    {
f14e283
--- 3040,3064 ----
f14e283
  	if (has_spell)
f14e283
  	{
f14e283
  	    int		len;
f14e283
+ 	    colnr_T	linecol = (colnr_T)(ptr - line);
f14e283
  	    hlf_T	spell_hlf = HLF_COUNT;
f14e283
  
f14e283
  	    pos = wp->w_cursor;
f14e283
  	    wp->w_cursor.lnum = lnum;
f14e283
! 	    wp->w_cursor.col = linecol;
f14e283
  	    len = spell_move_to(wp, FORWARD, TRUE, TRUE, &spell_hlf);
f14e283
+ 
f14e283
+ 	    /* spell_move_to() may call ml_get() and make "line" invalid */
f14e283
+ 	    line = ml_get_buf(wp->w_buffer, lnum, FALSE);
f14e283
+ 	    ptr = line + linecol;
f14e283
+ 
f14e283
  	    if (len == 0 || (int)wp->w_cursor.col > ptr - line)
f14e283
  	    {
f14e283
  		/* no bad word found at line start, don't check until end of a
f14e283
  		 * word */
f14e283
  		spell_hlf = HLF_COUNT;
f14e283
! 		word_end = (int)(spell_to_word_end(ptr, wp->w_buffer)
f14e283
! 								  - line + 1);
f14e283
  	    }
f14e283
  	    else
f14e283
  	    {
f14e283
*** ../vim-7.1.250/src/version.c	Wed Feb 13 18:35:23 2008
f14e283
--- src/version.c	Wed Feb 13 21:48:08 2008
f14e283
***************
f14e283
*** 668,669 ****
f14e283
--- 668,671 ----
f14e283
  {   /* Add new patch number below this line */
f14e283
+ /**/
f14e283
+     251,
f14e283
  /**/
f14e283
f14e283
-- 
f14e283
How To Keep A Healthy Level Of Insanity:
f14e283
6. In the memo field of all your checks, write "for sexual favors".
f14e283
f14e283
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
f14e283
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
f14e283
\\\        download, build and distribute -- http://www.A-A-P.org        ///
f14e283
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///