Karsten Hopp 44d845
To: vim-dev@vim.org
Karsten Hopp 44d845
Subject: Patch 7.2.036 (extra)
Karsten Hopp 44d845
Fcc: outbox
Karsten Hopp 44d845
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 44d845
Mime-Version: 1.0
Karsten Hopp 44d845
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 44d845
Content-Transfer-Encoding: 8bit
Karsten Hopp 44d845
------------
Karsten Hopp 44d845
Karsten Hopp 44d845
Patch 7.2.036 (extra)
Karsten Hopp 44d845
Problem:    Mismatches between alloc/malloc, free/vim_free,
Karsten Hopp 44d845
	    realloc/vim_realloc.
Karsten Hopp 44d845
Solution:   Use the right function. (Dominique Pelle)
Karsten Hopp 44d845
Files:	    src/gui_riscos.c, src/gui_w48.c, src/mbyte.c, src/os_vms.c,
Karsten Hopp 44d845
	    src/os_w32exe.c, src/os_win16.c
Karsten Hopp 44d845
Karsten Hopp 44d845
Karsten Hopp 44d845
*** ../vim-7.2.035/src/gui_riscos.c	Thu May 10 19:33:26 2007
Karsten Hopp 44d845
--- src/gui_riscos.c	Wed Nov 12 11:47:54 2008
Karsten Hopp 44d845
***************
Karsten Hopp 44d845
*** 695,701 ****
Karsten Hopp 44d845
  gui_mch_set_shellsize(width, height, min_width, min_height, base_width, base_height, direction)
Karsten Hopp 44d845
      int width;		/* In OS units */
Karsten Hopp 44d845
      int height;
Karsten Hopp 44d845
!     int min_width;	/* Smallest permissable window size (ignored) */
Karsten Hopp 44d845
      int min_height;
Karsten Hopp 44d845
      int base_width;	/* Space for scroll bars, etc */
Karsten Hopp 44d845
      int base_height;
Karsten Hopp 44d845
--- 695,701 ----
Karsten Hopp 44d845
  gui_mch_set_shellsize(width, height, min_width, min_height, base_width, base_height, direction)
Karsten Hopp 44d845
      int width;		/* In OS units */
Karsten Hopp 44d845
      int height;
Karsten Hopp 44d845
!     int min_width;	/* Smallest permissible window size (ignored) */
Karsten Hopp 44d845
      int min_height;
Karsten Hopp 44d845
      int base_width;	/* Space for scroll bars, etc */
Karsten Hopp 44d845
      int base_height;
Karsten Hopp 44d845
***************
Karsten Hopp 44d845
*** 863,869 ****
Karsten Hopp 44d845
      if (strncmp(file, "ZapFont\015", 8) == 0)
Karsten Hopp 44d845
  	return file;	/* Loaded OK! */
Karsten Hopp 44d845
  
Karsten Hopp 44d845
!     free(file);
Karsten Hopp 44d845
      return NULL;	/* Not a valid font file */
Karsten Hopp 44d845
  }
Karsten Hopp 44d845
  
Karsten Hopp 44d845
--- 863,869 ----
Karsten Hopp 44d845
      if (strncmp(file, "ZapFont\015", 8) == 0)
Karsten Hopp 44d845
  	return file;	/* Loaded OK! */
Karsten Hopp 44d845
  
Karsten Hopp 44d845
!     vim_free(file);
Karsten Hopp 44d845
      return NULL;	/* Not a valid font file */
Karsten Hopp 44d845
  }
Karsten Hopp 44d845
  
Karsten Hopp 44d845
*** ../vim-7.2.035/src/gui_w48.c	Thu Jul 24 20:50:23 2008
Karsten Hopp 44d845
--- src/gui_w48.c	Wed Nov 12 11:37:41 2008
Karsten Hopp 44d845
***************
Karsten Hopp 44d845
*** 3335,3341 ****
Karsten Hopp 44d845
  
Karsten Hopp 44d845
  /*
Karsten Hopp 44d845
   * Convert the string s to the proper format for a filter string by replacing
Karsten Hopp 44d845
!  * the \t and \n delimeters with \0.
Karsten Hopp 44d845
   * Returns the converted string in allocated memory.
Karsten Hopp 44d845
   *
Karsten Hopp 44d845
   * Keep in sync with convert_filterW() above!
Karsten Hopp 44d845
--- 3335,3341 ----
Karsten Hopp 44d845
  
Karsten Hopp 44d845
  /*
Karsten Hopp 44d845
   * Convert the string s to the proper format for a filter string by replacing
Karsten Hopp 44d845
!  * the \t and \n delimiters with \0.
Karsten Hopp 44d845
   * Returns the converted string in allocated memory.
Karsten Hopp 44d845
   *
Karsten Hopp 44d845
   * Keep in sync with convert_filterW() above!
Karsten Hopp 44d845
***************
Karsten Hopp 44d845
*** 3674,3680 ****
Karsten Hopp 44d845
   * Use "prog" as the name of the program and "cmdline" as the arguments.
Karsten Hopp 44d845
   * Copy the arguments to allocated memory.
Karsten Hopp 44d845
   * Return the number of arguments (including program name).
Karsten Hopp 44d845
!  * Return pointers to the arguments in "argvp".
Karsten Hopp 44d845
   * Return pointer to buffer in "tofree".
Karsten Hopp 44d845
   * Returns zero when out of memory.
Karsten Hopp 44d845
   */
Karsten Hopp 44d845
--- 3674,3681 ----
Karsten Hopp 44d845
   * Use "prog" as the name of the program and "cmdline" as the arguments.
Karsten Hopp 44d845
   * Copy the arguments to allocated memory.
Karsten Hopp 44d845
   * Return the number of arguments (including program name).
Karsten Hopp 44d845
!  * Return pointers to the arguments in "argvp".  Memory is allocated with
Karsten Hopp 44d845
!  * malloc(), use free() instead of vim_free().
Karsten Hopp 44d845
   * Return pointer to buffer in "tofree".
Karsten Hopp 44d845
   * Returns zero when out of memory.
Karsten Hopp 44d845
   */
Karsten Hopp 44d845
***************
Karsten Hopp 44d845
*** 3692,3697 ****
Karsten Hopp 44d845
--- 3693,3700 ----
Karsten Hopp 44d845
      char	**argv = NULL;
Karsten Hopp 44d845
      int		round;
Karsten Hopp 44d845
  
Karsten Hopp 44d845
+     *tofree = NULL;
Karsten Hopp 44d845
+ 
Karsten Hopp 44d845
  #ifdef FEAT_MBYTE
Karsten Hopp 44d845
      /* Try using the Unicode version first, it takes care of conversion when
Karsten Hopp 44d845
       * 'encoding' is changed. */
Karsten Hopp 44d845
***************
Karsten Hopp 44d845
*** 3802,3816 ****
Karsten Hopp 44d845
  	    argv = (char **)malloc((argc + 1) * sizeof(char *));
Karsten Hopp 44d845
  	    if (argv == NULL )
Karsten Hopp 44d845
  	    {
Karsten Hopp 44d845
! 		vim_free(newcmdline);
Karsten Hopp 44d845
  		return 0;		   /* malloc error */
Karsten Hopp 44d845
  	    }
Karsten Hopp 44d845
  	    pnew = newcmdline;
Karsten Hopp 44d845
  	}
Karsten Hopp 44d845
      }
Karsten Hopp 44d845
  
Karsten Hopp 44d845
  done:
Karsten Hopp 44d845
- 
Karsten Hopp 44d845
      argv[argc] = NULL;		/* NULL-terminated list */
Karsten Hopp 44d845
      *argvp = argv;
Karsten Hopp 44d845
      return argc;
Karsten Hopp 44d845
--- 3805,3819 ----
Karsten Hopp 44d845
  	    argv = (char **)malloc((argc + 1) * sizeof(char *));
Karsten Hopp 44d845
  	    if (argv == NULL )
Karsten Hopp 44d845
  	    {
Karsten Hopp 44d845
! 		free(newcmdline);
Karsten Hopp 44d845
  		return 0;		   /* malloc error */
Karsten Hopp 44d845
  	    }
Karsten Hopp 44d845
  	    pnew = newcmdline;
Karsten Hopp 44d845
+ 	    *tofree = newcmdline;
Karsten Hopp 44d845
  	}
Karsten Hopp 44d845
      }
Karsten Hopp 44d845
  
Karsten Hopp 44d845
  done:
Karsten Hopp 44d845
      argv[argc] = NULL;		/* NULL-terminated list */
Karsten Hopp 44d845
      *argvp = argv;
Karsten Hopp 44d845
      return argc;
Karsten Hopp 44d845
*** ../vim-7.2.035/src/os_vms.c	Wed Aug  6 18:38:52 2008
Karsten Hopp 44d845
--- src/os_vms.c	Wed Nov 12 11:42:12 2008
Karsten Hopp 44d845
***************
Karsten Hopp 44d845
*** 228,234 ****
Karsten Hopp 44d845
      else if ((sbuf = getenv((char *)lognam)))
Karsten Hopp 44d845
      {
Karsten Hopp 44d845
  	lengte = strlen(sbuf) + 1;
Karsten Hopp 44d845
! 	cp = (char_u *)malloc((size_t)lengte);
Karsten Hopp 44d845
  	if (cp)
Karsten Hopp 44d845
  	    strcpy((char *)cp, sbuf);
Karsten Hopp 44d845
  	return cp;
Karsten Hopp 44d845
--- 228,234 ----
Karsten Hopp 44d845
      else if ((sbuf = getenv((char *)lognam)))
Karsten Hopp 44d845
      {
Karsten Hopp 44d845
  	lengte = strlen(sbuf) + 1;
Karsten Hopp 44d845
! 	cp = (char_u *)alloc((size_t)lengte);
Karsten Hopp 44d845
  	if (cp)
Karsten Hopp 44d845
  	    strcpy((char *)cp, sbuf);
Karsten Hopp 44d845
  	return cp;
Karsten Hopp 44d845
***************
Karsten Hopp 44d845
*** 381,387 ****
Karsten Hopp 44d845
      if (--vms_match_free == 0) {
Karsten Hopp 44d845
  	/* add more space to store matches */
Karsten Hopp 44d845
  	vms_match_alloced += EXPL_ALLOC_INC;
Karsten Hopp 44d845
! 	vms_fmatch = (char_u **)realloc(vms_fmatch,
Karsten Hopp 44d845
  		sizeof(char **) * vms_match_alloced);
Karsten Hopp 44d845
  	if (!vms_fmatch)
Karsten Hopp 44d845
  	    return 0;
Karsten Hopp 44d845
--- 381,387 ----
Karsten Hopp 44d845
      if (--vms_match_free == 0) {
Karsten Hopp 44d845
  	/* add more space to store matches */
Karsten Hopp 44d845
  	vms_match_alloced += EXPL_ALLOC_INC;
Karsten Hopp 44d845
! 	vms_fmatch = (char_u **)vim_realloc(vms_fmatch,
Karsten Hopp 44d845
  		sizeof(char **) * vms_match_alloced);
Karsten Hopp 44d845
  	if (!vms_fmatch)
Karsten Hopp 44d845
  	    return 0;
Karsten Hopp 44d845
***************
Karsten Hopp 44d845
*** 460,466 ****
Karsten Hopp 44d845
  	    if (--files_free < 1)
Karsten Hopp 44d845
  	    {
Karsten Hopp 44d845
  		files_alloced += EXPL_ALLOC_INC;
Karsten Hopp 44d845
! 		*file = (char_u **)realloc(*file,
Karsten Hopp 44d845
  		    sizeof(char_u **) * files_alloced);
Karsten Hopp 44d845
  		if (*file == NULL)
Karsten Hopp 44d845
  		{
Karsten Hopp 44d845
--- 460,466 ----
Karsten Hopp 44d845
  	    if (--files_free < 1)
Karsten Hopp 44d845
  	    {
Karsten Hopp 44d845
  		files_alloced += EXPL_ALLOC_INC;
Karsten Hopp 44d845
! 		*file = (char_u **)vim_realloc(*file,
Karsten Hopp 44d845
  		    sizeof(char_u **) * files_alloced);
Karsten Hopp 44d845
  		if (*file == NULL)
Karsten Hopp 44d845
  		{
Karsten Hopp 44d845
***************
Karsten Hopp 44d845
*** 614,627 ****
Karsten Hopp 44d845
      {
Karsten Hopp 44d845
  	buflen = len + 128;
Karsten Hopp 44d845
  	if (buf)
Karsten Hopp 44d845
! 	    buf = (char *)realloc(buf, buflen);
Karsten Hopp 44d845
  	else
Karsten Hopp 44d845
! 	    buf = (char *)calloc(buflen, sizeof(char));
Karsten Hopp 44d845
      }
Karsten Hopp 44d845
  
Karsten Hopp 44d845
  #ifdef DEBUG
Karsten Hopp 44d845
       char		 *tmpbuf = NULL;
Karsten Hopp 44d845
!      tmpbuf = (char *)calloc(buflen, sizeof(char));
Karsten Hopp 44d845
       strcpy(tmpbuf, instring);
Karsten Hopp 44d845
  #endif
Karsten Hopp 44d845
  
Karsten Hopp 44d845
--- 614,627 ----
Karsten Hopp 44d845
      {
Karsten Hopp 44d845
  	buflen = len + 128;
Karsten Hopp 44d845
  	if (buf)
Karsten Hopp 44d845
! 	    buf = (char *)vim_realloc(buf, buflen);
Karsten Hopp 44d845
  	else
Karsten Hopp 44d845
! 	    buf = (char *)alloc(buflen * sizeof(char));
Karsten Hopp 44d845
      }
Karsten Hopp 44d845
  
Karsten Hopp 44d845
  #ifdef DEBUG
Karsten Hopp 44d845
       char		 *tmpbuf = NULL;
Karsten Hopp 44d845
!      tmpbuf = (char *)alloc(buflen * sizeof(char));
Karsten Hopp 44d845
       strcpy(tmpbuf, instring);
Karsten Hopp 44d845
  #endif
Karsten Hopp 44d845
  
Karsten Hopp 44d845
*** ../vim-7.2.035/src/os_w32exe.c	Fri Jul  1 00:06:20 2005
Karsten Hopp 44d845
--- src/os_w32exe.c	Wed Nov 12 11:45:43 2008
Karsten Hopp 44d845
***************
Karsten Hopp 44d845
*** 129,135 ****
Karsten Hopp 44d845
  errout:
Karsten Hopp 44d845
  #endif
Karsten Hopp 44d845
      free(argv);
Karsten Hopp 44d845
!     free(tofree);
Karsten Hopp 44d845
  #ifdef FEAT_MBYTE
Karsten Hopp 44d845
      free_cmd_argsW();
Karsten Hopp 44d845
  #endif
Karsten Hopp 44d845
--- 129,136 ----
Karsten Hopp 44d845
  errout:
Karsten Hopp 44d845
  #endif
Karsten Hopp 44d845
      free(argv);
Karsten Hopp 44d845
!     if (tofree != NULL)
Karsten Hopp 44d845
! 	free(tofree);
Karsten Hopp 44d845
  #ifdef FEAT_MBYTE
Karsten Hopp 44d845
      free_cmd_argsW();
Karsten Hopp 44d845
  #endif
Karsten Hopp 44d845
*** ../vim-7.2.035/src/os_win16.c	Wed Jun 25 00:49:34 2008
Karsten Hopp 44d845
--- src/os_win16.c	Wed Nov 12 11:45:53 2008
Karsten Hopp 44d845
***************
Karsten Hopp 44d845
*** 121,127 ****
Karsten Hopp 44d845
      pmain(argc, argv);
Karsten Hopp 44d845
  
Karsten Hopp 44d845
      free(argv);
Karsten Hopp 44d845
!     free(tofree);
Karsten Hopp 44d845
  
Karsten Hopp 44d845
      return 0;
Karsten Hopp 44d845
  }
Karsten Hopp 44d845
--- 121,128 ----
Karsten Hopp 44d845
      pmain(argc, argv);
Karsten Hopp 44d845
  
Karsten Hopp 44d845
      free(argv);
Karsten Hopp 44d845
!     if (tofree != NULL)
Karsten Hopp 44d845
! 	free(tofree);
Karsten Hopp 44d845
  
Karsten Hopp 44d845
      return 0;
Karsten Hopp 44d845
  }
Karsten Hopp 44d845
*** ../vim-7.2.035/src/version.c	Wed Nov 12 13:07:48 2008
Karsten Hopp 44d845
--- src/version.c	Wed Nov 12 13:28:51 2008
Karsten Hopp 44d845
***************
Karsten Hopp 44d845
*** 678,679 ****
Karsten Hopp 44d845
--- 678,681 ----
Karsten Hopp 44d845
  {   /* Add new patch number below this line */
Karsten Hopp 44d845
+ /**/
Karsten Hopp 44d845
+     36,
Karsten Hopp 44d845
  /**/
Karsten Hopp 44d845
Karsten Hopp 44d845
-- 
Karsten Hopp 44d845
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 44d845
239. You think "surfing" is something you do on dry land.
Karsten Hopp 44d845
Karsten Hopp 44d845
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 44d845
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 44d845
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 44d845
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///