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