a82632f
To: vim_dev@googlegroups.com
a82632f
Subject: Patch 7.3.051
a82632f
Fcc: outbox
a82632f
From: Bram Moolenaar <Bram@moolenaar.net>
a82632f
Mime-Version: 1.0
a82632f
Content-Type: text/plain; charset=UTF-8
a82632f
Content-Transfer-Encoding: 8bit
a82632f
------------
a82632f
a82632f
Patch 7.3.051
a82632f
Problem:    Crash when $PATH is empty.
a82632f
Solution:   Check for vim_getenv() returning NULL. (Yasuhiro Matsumoto)
a82632f
Files:	    src/ex_getln.c, src/os_win32.c
a82632f
a82632f
a82632f
*** ../vim-7.3.050/src/ex_getln.c	2010-10-27 12:58:19.000000000 +0200
a82632f
--- src/ex_getln.c	2010-11-10 15:31:33.000000000 +0100
a82632f
***************
a82632f
*** 4747,4753 ****
a82632f
--- 4747,4757 ----
a82632f
  			    || (pat[1] == '.' && vim_ispathsep(pat[2])))))
a82632f
  	path = (char_u *)".";
a82632f
      else
a82632f
+     {
a82632f
  	path = vim_getenv((char_u *)"PATH", &mustfree);
a82632f
+ 	if (path == NULL)
a82632f
+ 	    path = (char_u *)"";
a82632f
+     }
a82632f
  
a82632f
      /*
a82632f
       * Go over all directories in $PATH.  Expand matches in that directory and
a82632f
*** ../vim-7.3.050/src/os_win32.c	2010-10-27 12:17:54.000000000 +0200
a82632f
--- src/os_win32.c	2010-11-10 15:30:36.000000000 +0100
a82632f
***************
a82632f
*** 211,223 ****
a82632f
      static void
a82632f
  get_exe_name(void)
a82632f
  {
a82632f
!     char	temp[MAXPATHL];
a82632f
      char_u	*p;
a82632f
  
a82632f
      if (exe_name == NULL)
a82632f
      {
a82632f
  	/* store the name of the executable, may be used for $VIM */
a82632f
! 	GetModuleFileName(NULL, temp, MAXPATHL - 1);
a82632f
  	if (*temp != NUL)
a82632f
  	    exe_name = FullName_save((char_u *)temp, FALSE);
a82632f
      }
a82632f
--- 211,226 ----
a82632f
      static void
a82632f
  get_exe_name(void)
a82632f
  {
a82632f
!     /* Maximum length of $PATH is more than MAXPATHL.  8191 is often mentioned
a82632f
!      * as the maximum length that works (plus a NUL byte). */
a82632f
! #define MAX_ENV_PATH_LEN 8192
a82632f
!     char	temp[MAX_ENV_PATH_LEN];
a82632f
      char_u	*p;
a82632f
  
a82632f
      if (exe_name == NULL)
a82632f
      {
a82632f
  	/* store the name of the executable, may be used for $VIM */
a82632f
! 	GetModuleFileName(NULL, temp, MAX_ENV_PATH_LEN - 1);
a82632f
  	if (*temp != NUL)
a82632f
  	    exe_name = FullName_save((char_u *)temp, FALSE);
a82632f
      }
a82632f
***************
a82632f
*** 232,241 ****
a82632f
  	     * "!xxd" it's found in our starting directory.  Needed because
a82632f
  	     * SearchPath() also looks there. */
a82632f
  	    p = mch_getenv("PATH");
a82632f
! 	    if (STRLEN(p) + STRLEN(exe_path) + 2 < MAXPATHL)
a82632f
  	    {
a82632f
! 		STRCPY(temp, p);
a82632f
! 		STRCAT(temp, ";");
a82632f
  		STRCAT(temp, exe_path);
a82632f
  		vim_setenv((char_u *)"PATH", temp);
a82632f
  	    }
a82632f
--- 235,250 ----
a82632f
  	     * "!xxd" it's found in our starting directory.  Needed because
a82632f
  	     * SearchPath() also looks there. */
a82632f
  	    p = mch_getenv("PATH");
a82632f
! 	    if (p == NULL
a82632f
! 		       || STRLEN(p) + STRLEN(exe_path) + 2 < MAX_ENV_PATH_LEN)
a82632f
  	    {
a82632f
! 		if (p == NULL || *p == NUL)
a82632f
! 		    temp[0] = NUL;
a82632f
! 		else
a82632f
! 		{
a82632f
! 		    STRCPY(temp, p);
a82632f
! 		    STRCAT(temp, ";");
a82632f
! 		}
a82632f
  		STRCAT(temp, exe_path);
a82632f
  		vim_setenv((char_u *)"PATH", temp);
a82632f
  	    }
a82632f
*** ../vim-7.3.050/src/version.c	2010-11-03 22:32:18.000000000 +0100
a82632f
--- src/version.c	2010-11-10 15:34:43.000000000 +0100
a82632f
***************
a82632f
*** 716,717 ****
a82632f
--- 716,719 ----
a82632f
  {   /* Add new patch number below this line */
a82632f
+ /**/
a82632f
+     51,
a82632f
  /**/
a82632f
a82632f
-- 
a82632f
SIGFUN -- signature too funny (core dumped)
a82632f
a82632f
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
a82632f
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
a82632f
\\\        download, build and distribute -- http://www.A-A-P.org        ///
a82632f
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///