81c2858
To: vim-dev@vim.org
81c2858
Subject: Patch 7.2.153
81c2858
Fcc: outbox
81c2858
From: Bram Moolenaar <Bram@moolenaar.net>
81c2858
Mime-Version: 1.0
81c2858
Content-Type: text/plain; charset=ISO-8859-1
81c2858
Content-Transfer-Encoding: 8bit
81c2858
------------
81c2858
81c2858
Patch 7.2.153
81c2858
Problem:    Memory leak for ":recover empty_dir/".
81c2858
Solution:   Free files[] when it becomes empty. (Dominique Pelle)
81c2858
Files:	    src/memline.c
81c2858
81c2858
81c2858
*** ../vim-7.2.152/src/memline.c	Sun Jul 13 19:40:43 2008
81c2858
--- src/memline.c	Wed Apr 22 11:48:35 2009
81c2858
***************
81c2858
*** 1554,1563 ****
81c2858
  	    for (i = 0; i < num_files; ++i)
81c2858
  		if (fullpathcmp(p, files[i], TRUE) & FPC_SAME)
81c2858
  		{
81c2858
  		    vim_free(files[i]);
81c2858
! 		    --num_files;
81c2858
! 		    for ( ; i < num_files; ++i)
81c2858
! 			files[i] = files[i + 1];
81c2858
  		}
81c2858
  	}
81c2858
  	if (nr > 0)
81c2858
--- 1554,1568 ----
81c2858
  	    for (i = 0; i < num_files; ++i)
81c2858
  		if (fullpathcmp(p, files[i], TRUE) & FPC_SAME)
81c2858
  		{
81c2858
+ 		    /* Remove the name from files[i].  Move further entries
81c2858
+ 		     * down.  When the array becomes empty free it here, since
81c2858
+ 		     * FreeWild() won't be called below. */
81c2858
  		    vim_free(files[i]);
81c2858
! 		    if (--num_files == 0)
81c2858
! 			vim_free(files);
81c2858
! 		    else
81c2858
! 			for ( ; i < num_files; ++i)
81c2858
! 			    files[i] = files[i + 1];
81c2858
  		}
81c2858
  	}
81c2858
  	if (nr > 0)
81c2858
***************
81c2858
*** 3522,3528 ****
81c2858
  	    if (errno == EINVAL || errno == ENOENT)
81c2858
  	    {
81c2858
  		/* Found non-symlink or not existing file, stop here.
81c2858
! 		 * When at the first level use the unmodifed name, skip the
81c2858
  		 * call to vim_FullName(). */
81c2858
  		if (depth == 1)
81c2858
  		    return FAIL;
81c2858
--- 3527,3533 ----
81c2858
  	    if (errno == EINVAL || errno == ENOENT)
81c2858
  	    {
81c2858
  		/* Found non-symlink or not existing file, stop here.
81c2858
! 		 * When at the first level use the unmodified name, skip the
81c2858
  		 * call to vim_FullName(). */
81c2858
  		if (depth == 1)
81c2858
  		    return FAIL;
81c2858
***************
81c2858
*** 4560,4566 ****
81c2858
  			buf->b_ml.ml_chunksize + curix,
81c2858
  			(buf->b_ml.ml_usedchunks - curix) *
81c2858
  			sizeof(chunksize_T));
81c2858
! 	    /* Compute length of first half of lines in the splitted chunk */
81c2858
  	    size = 0;
81c2858
  	    linecnt = 0;
81c2858
  	    while (curline < buf->b_ml.ml_line_count
81c2858
--- 4568,4574 ----
81c2858
  			buf->b_ml.ml_chunksize + curix,
81c2858
  			(buf->b_ml.ml_usedchunks - curix) *
81c2858
  			sizeof(chunksize_T));
81c2858
! 	    /* Compute length of first half of lines in the split chunk */
81c2858
  	    size = 0;
81c2858
  	    linecnt = 0;
81c2858
  	    while (curline < buf->b_ml.ml_line_count
81c2858
*** ../vim-7.2.152/src/version.c	Wed Apr 22 14:42:26 2009
81c2858
--- src/version.c	Wed Apr 22 15:34:18 2009
81c2858
***************
81c2858
*** 678,679 ****
81c2858
--- 678,681 ----
81c2858
  {   /* Add new patch number below this line */
81c2858
+ /**/
81c2858
+     153,
81c2858
  /**/
81c2858
81c2858
-- 
81c2858
Windows
81c2858
M!uqoms
81c2858
81c2858
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
81c2858
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
81c2858
\\\        download, build and distribute -- http://www.A-A-P.org        ///
81c2858
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///