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