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