6a878e0
To: vim_dev@googlegroups.com
6a878e0
Subject: Patch 7.3.169
6a878e0
Fcc: outbox
6a878e0
From: Bram Moolenaar <Bram@moolenaar.net>
6a878e0
Mime-Version: 1.0
6a878e0
Content-Type: text/plain; charset=UTF-8
6a878e0
Content-Transfer-Encoding: 8bit
6a878e0
------------
6a878e0
6a878e0
Patch 7.3.169
6a878e0
Problem:    Freeing memory already freed, warning from static code analyzer.
6a878e0
Solution:   Initialize pointers to NULL, correct use of "mustfree". (partly by
6a878e0
	    Dominique Pelle)
6a878e0
Files:	    src/mis1.c
6a878e0
6a878e0
6a878e0
*** ../vim-7.3.168/src/misc1.c	2011-04-28 13:01:59.000000000 +0200
6a878e0
--- src/misc1.c	2011-04-28 17:42:00.000000000 +0200
6a878e0
***************
6a878e0
*** 3505,3511 ****
6a878e0
      if (enc_utf8 && var != NULL)
6a878e0
      {
6a878e0
  	int	len;
6a878e0
! 	char_u  *pp;
6a878e0
  
6a878e0
  	/* Convert from active codepage to UTF-8.  Other conversions are
6a878e0
  	 * not done, because they would fail for non-ASCII characters. */
6a878e0
--- 3505,3511 ----
6a878e0
      if (enc_utf8 && var != NULL)
6a878e0
      {
6a878e0
  	int	len;
6a878e0
! 	char_u  *pp = NULL;
6a878e0
  
6a878e0
  	/* Convert from active codepage to UTF-8.  Other conversions are
6a878e0
  	 * not done, because they would fail for non-ASCII characters. */
6a878e0
***************
6a878e0
*** 3872,3882 ****
6a878e0
   * Vim's version of getenv().
6a878e0
   * Special handling of $HOME, $VIM and $VIMRUNTIME.
6a878e0
   * Also does ACP to 'enc' conversion for Win32.
6a878e0
   */
6a878e0
      char_u *
6a878e0
  vim_getenv(name, mustfree)
6a878e0
      char_u	*name;
6a878e0
!     int		*mustfree;	/* set to TRUE when returned is allocated */
6a878e0
  {
6a878e0
      char_u	*p;
6a878e0
      char_u	*pend;
6a878e0
--- 3872,3884 ----
6a878e0
   * Vim's version of getenv().
6a878e0
   * Special handling of $HOME, $VIM and $VIMRUNTIME.
6a878e0
   * Also does ACP to 'enc' conversion for Win32.
6a878e0
+  * "mustfree" is set to TRUE when returned is allocated, it must be
6a878e0
+  * initialized to FALSE by the caller.
6a878e0
   */
6a878e0
      char_u *
6a878e0
  vim_getenv(name, mustfree)
6a878e0
      char_u	*name;
6a878e0
!     int		*mustfree;
6a878e0
  {
6a878e0
      char_u	*p;
6a878e0
      char_u	*pend;
6a878e0
***************
6a878e0
*** 3898,3904 ****
6a878e0
  	if (enc_utf8)
6a878e0
  	{
6a878e0
  	    int	    len;
6a878e0
! 	    char_u  *pp;
6a878e0
  
6a878e0
  	    /* Convert from active codepage to UTF-8.  Other conversions are
6a878e0
  	     * not done, because they would fail for non-ASCII characters. */
6a878e0
--- 3900,3906 ----
6a878e0
  	if (enc_utf8)
6a878e0
  	{
6a878e0
  	    int	    len;
6a878e0
! 	    char_u  *pp = NULL;
6a878e0
  
6a878e0
  	    /* Convert from active codepage to UTF-8.  Other conversions are
6a878e0
  	     * not done, because they would fail for non-ASCII characters. */
6a878e0
***************
6a878e0
*** 3942,3948 ****
6a878e0
  	    if (enc_utf8)
6a878e0
  	    {
6a878e0
  		int	len;
6a878e0
! 		char_u  *pp;
6a878e0
  
6a878e0
  		/* Convert from active codepage to UTF-8.  Other conversions
6a878e0
  		 * are not done, because they would fail for non-ASCII
6a878e0
--- 3944,3950 ----
6a878e0
  	    if (enc_utf8)
6a878e0
  	    {
6a878e0
  		int	len;
6a878e0
! 		char_u  *pp = NULL;
6a878e0
  
6a878e0
  		/* Convert from active codepage to UTF-8.  Other conversions
6a878e0
  		 * are not done, because they would fail for non-ASCII
6a878e0
***************
6a878e0
*** 3950,3956 ****
6a878e0
  		acp_to_enc(p, (int)STRLEN(p), &pp, &len;;
6a878e0
  		if (pp != NULL)
6a878e0
  		{
6a878e0
! 		    if (mustfree)
6a878e0
  			vim_free(p);
6a878e0
  		    p = pp;
6a878e0
  		    *mustfree = TRUE;
6a878e0
--- 3952,3958 ----
6a878e0
  		acp_to_enc(p, (int)STRLEN(p), &pp, &len;;
6a878e0
  		if (pp != NULL)
6a878e0
  		{
6a878e0
! 		    if (*mustfree)
6a878e0
  			vim_free(p);
6a878e0
  		    p = pp;
6a878e0
  		    *mustfree = TRUE;
6a878e0
*** ../vim-7.3.168/src/version.c	2011-04-28 17:30:05.000000000 +0200
6a878e0
--- src/version.c	2011-04-28 17:48:04.000000000 +0200
6a878e0
***************
6a878e0
*** 716,717 ****
6a878e0
--- 716,719 ----
6a878e0
  {   /* Add new patch number below this line */
6a878e0
+ /**/
6a878e0
+     169,
6a878e0
  /**/
6a878e0
6a878e0
-- 
6a878e0
A day without sunshine is like, well, night.
6a878e0
6a878e0
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
6a878e0
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
6a878e0
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
6a878e0
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///