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