effbfeb
To: vim-dev@vim.org
effbfeb
Subject: About patch 7.1.127
effbfeb
Fcc: outbox
effbfeb
From: Bram Moolenaar <Bram@moolenaar.net>
effbfeb
Mime-Version: 1.0
effbfeb
Content-Type: text/plain; charset=ISO-8859-1
effbfeb
Content-Transfer-Encoding: 8bit
effbfeb
------------
effbfeb
effbfeb
Patch 7.1.127
effbfeb
Problem:    Memory leak when doing cmdline completion. (Dominique Pelle)
effbfeb
Solution:   Free "orig" argument of ExpandOne() when it's not used.
effbfeb
Files:	    src/ex_getln.c
effbfeb
effbfeb
effbfeb
*** ../vim-7.1.126/src/ex_getln.c	Sat Sep 29 14:15:00 2007
effbfeb
--- src/ex_getln.c	Sun Sep 30 17:55:47 2007
effbfeb
***************
effbfeb
*** 3316,3321 ****
effbfeb
--- 3316,3325 ----
effbfeb
   * Return a pointer to alloced memory containing the new string.
effbfeb
   * Return NULL for failure.
effbfeb
   *
effbfeb
+  * "orig" is the originally expanded string, copied to allocated memory.  It
effbfeb
+  * should either be kept in orig_save or freed.  When "mode" is WILD_NEXT or
effbfeb
+  * WILD_PREV "orig" should be NULL.
effbfeb
+  *
effbfeb
   * Results are cached in xp->xp_files and xp->xp_numfiles, except when "mode"
effbfeb
   * is WILD_EXPAND_FREE or WILD_ALL.
effbfeb
   *
effbfeb
***************
effbfeb
*** 3400,3406 ****
effbfeb
  	    return NULL;
effbfeb
      }
effbfeb
  
effbfeb
! /* free old names */
effbfeb
      if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST)
effbfeb
      {
effbfeb
  	FreeWild(xp->xp_numfiles, xp->xp_files);
effbfeb
--- 3404,3410 ----
effbfeb
  	    return NULL;
effbfeb
      }
effbfeb
  
effbfeb
!     /* free old names */
effbfeb
      if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST)
effbfeb
      {
effbfeb
  	FreeWild(xp->xp_numfiles, xp->xp_files);
effbfeb
***************
effbfeb
*** 3540,3545 ****
effbfeb
--- 3544,3553 ----
effbfeb
  
effbfeb
      if (mode == WILD_EXPAND_FREE || mode == WILD_ALL)
effbfeb
  	ExpandCleanup(xp);
effbfeb
+ 
effbfeb
+     /* Free "orig" if it wasn't stored in "orig_save". */
effbfeb
+     if (orig != orig_save)
effbfeb
+ 	vim_free(orig);
effbfeb
  
effbfeb
      return ss;
effbfeb
  }
effbfeb
*** ../vim-7.1.126/src/version.c	Sun Sep 30 14:00:41 2007
effbfeb
--- src/version.c	Sun Sep 30 14:20:14 2007
effbfeb
***************
effbfeb
*** 668,669 ****
effbfeb
--- 668,671 ----
effbfeb
  {   /* Add new patch number below this line */
effbfeb
+ /**/
effbfeb
+     127,
effbfeb
  /**/
effbfeb
effbfeb
-- 
effbfeb
A M00se once bit my sister ...
effbfeb
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
effbfeb
effbfeb
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
effbfeb
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
effbfeb
\\\        download, build and distribute -- http://www.A-A-P.org        ///
effbfeb
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///