Karsten Hopp a49bae
To: vim_dev@googlegroups.com
Karsten Hopp a49bae
Subject: Patch 7.3.286
Karsten Hopp a49bae
Fcc: outbox
Karsten Hopp a49bae
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp a49bae
Mime-Version: 1.0
Karsten Hopp a49bae
Content-Type: text/plain; charset=UTF-8
Karsten Hopp a49bae
Content-Transfer-Encoding: 8bit
Karsten Hopp a49bae
------------
Karsten Hopp a49bae
Karsten Hopp a49bae
Patch 7.3.286
Karsten Hopp a49bae
Problem:    Crash when using "zd" on a large number of folds. (Sam King)
Karsten Hopp a49bae
Solution:   Recompute pointer after reallocating array.  Move fewer entries
Karsten Hopp a49bae
	    when making room.
Karsten Hopp a49bae
Files:	    src/fold.c
Karsten Hopp a49bae
Karsten Hopp a49bae
Karsten Hopp a49bae
*** ../vim-7.3.285/src/fold.c	2010-08-15 21:57:27.000000000 +0200
Karsten Hopp a49bae
--- src/fold.c	2011-08-26 16:03:56.000000000 +0200
Karsten Hopp a49bae
***************
Karsten Hopp a49bae
*** 1469,1479 ****
Karsten Hopp a49bae
      }
Karsten Hopp a49bae
      else
Karsten Hopp a49bae
      {
Karsten Hopp a49bae
! 	/* move nested folds one level up, to overwrite the fold that is
Karsten Hopp a49bae
  	 * deleted. */
Karsten Hopp a49bae
  	moved = fp->fd_nested.ga_len;
Karsten Hopp a49bae
  	if (ga_grow(gap, (int)(moved - 1)) == OK)
Karsten Hopp a49bae
  	{
Karsten Hopp a49bae
  	    /* adjust fd_top and fd_flags for the moved folds */
Karsten Hopp a49bae
  	    nfp = (fold_T *)fp->fd_nested.ga_data;
Karsten Hopp a49bae
  	    for (i = 0; i < moved; ++i)
Karsten Hopp a49bae
--- 1469,1482 ----
Karsten Hopp a49bae
      }
Karsten Hopp a49bae
      else
Karsten Hopp a49bae
      {
Karsten Hopp a49bae
! 	/* Move nested folds one level up, to overwrite the fold that is
Karsten Hopp a49bae
  	 * deleted. */
Karsten Hopp a49bae
  	moved = fp->fd_nested.ga_len;
Karsten Hopp a49bae
  	if (ga_grow(gap, (int)(moved - 1)) == OK)
Karsten Hopp a49bae
  	{
Karsten Hopp a49bae
+ 	    /* Get "fp" again, the array may have been reallocated. */
Karsten Hopp a49bae
+ 	    fp = (fold_T *)gap->ga_data + idx;
Karsten Hopp a49bae
+ 
Karsten Hopp a49bae
  	    /* adjust fd_top and fd_flags for the moved folds */
Karsten Hopp a49bae
  	    nfp = (fold_T *)fp->fd_nested.ga_data;
Karsten Hopp a49bae
  	    for (i = 0; i < moved; ++i)
Karsten Hopp a49bae
***************
Karsten Hopp a49bae
*** 1486,1494 ****
Karsten Hopp a49bae
  	    }
Karsten Hopp a49bae
  
Karsten Hopp a49bae
  	    /* move the existing folds down to make room */
Karsten Hopp a49bae
! 	    if (idx < gap->ga_len)
Karsten Hopp a49bae
  		mch_memmove(fp + moved, fp + 1,
Karsten Hopp a49bae
! 					sizeof(fold_T) * (gap->ga_len - idx));
Karsten Hopp a49bae
  	    /* move the contained folds one level up */
Karsten Hopp a49bae
  	    mch_memmove(fp, nfp, (size_t)(sizeof(fold_T) * moved));
Karsten Hopp a49bae
  	    vim_free(nfp);
Karsten Hopp a49bae
--- 1489,1497 ----
Karsten Hopp a49bae
  	    }
Karsten Hopp a49bae
  
Karsten Hopp a49bae
  	    /* move the existing folds down to make room */
Karsten Hopp a49bae
! 	    if (idx + 1 < gap->ga_len)
Karsten Hopp a49bae
  		mch_memmove(fp + moved, fp + 1,
Karsten Hopp a49bae
! 				  sizeof(fold_T) * (gap->ga_len - (idx + 1)));
Karsten Hopp a49bae
  	    /* move the contained folds one level up */
Karsten Hopp a49bae
  	    mch_memmove(fp, nfp, (size_t)(sizeof(fold_T) * moved));
Karsten Hopp a49bae
  	    vim_free(nfp);
Karsten Hopp a49bae
*** ../vim-7.3.285/src/version.c	2011-08-19 22:28:58.000000000 +0200
Karsten Hopp a49bae
--- src/version.c	2011-08-26 16:07:59.000000000 +0200
Karsten Hopp a49bae
***************
Karsten Hopp a49bae
*** 711,712 ****
Karsten Hopp a49bae
--- 711,714 ----
Karsten Hopp a49bae
  {   /* Add new patch number below this line */
Karsten Hopp a49bae
+ /**/
Karsten Hopp a49bae
+     286,
Karsten Hopp a49bae
  /**/
Karsten Hopp a49bae
Karsten Hopp a49bae
-- 
Karsten Hopp a49bae
To keep milk from turning sour: Keep it in the cow.
Karsten Hopp a49bae
Karsten Hopp a49bae
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp a49bae
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp a49bae
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp a49bae
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///