0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

updated for version 7.3.051

Problem:    Crash when /home/mool/bin:/usr/local/sbin:/usr/local/bin:/home/mool/java/jdk/bin:/bin:/sbin:/usr/bin:/usr/games:/usr/sbin:/usr/X11R6/bin:/usr/local/linux-jdk1.3.1/bin:/usr/local/lib/python2.2/Tools/idle is empty.
Solution:   Check for vim_getenv() returning NULL. (Yasuhiro Matsumoto)
This commit is contained in:
Bram Moolenaar
2010-11-10 15:37:05 +01:00
parent 22e193ddd5
commit 27d9eceb66
3 changed files with 20 additions and 5 deletions

View File

@@ -211,13 +211,16 @@ static char_u *exe_path = NULL;
static void
get_exe_name(void)
{
char temp[MAXPATHL];
/* 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, MAXPATHL - 1);
GetModuleFileName(NULL, temp, MAX_ENV_PATH_LEN - 1);
if (*temp != NUL)
exe_name = FullName_save((char_u *)temp, FALSE);
}
@@ -232,10 +235,16 @@ get_exe_name(void)
* "!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)
if (p == NULL
|| STRLEN(p) + STRLEN(exe_path) + 2 < MAX_ENV_PATH_LEN)
{
STRCPY(temp, p);
STRCAT(temp, ";");
if (p == NULL || *p == NUL)
temp[0] = NUL;
else
{
STRCPY(temp, p);
STRCAT(temp, ";");
}
STRCAT(temp, exe_path);
vim_setenv((char_u *)"PATH", temp);
}