On Mon, Nov 08, 2010 at 08:08:17PM -0800, mattn wrote: > vim crash when $PATH is empty. > below is a patch. check please. > > - Yasuhiro Matsumoto > > diff -r 1ccc1ace9e5b src/ex_getln.c > --- a/src/ex_getln.c Wed Nov 03 22:32:24 2010 +0100 > +++ b/src/ex_getln.c Tue Nov 09 13:02:54 2010 +0900 > @@ -4746,8 +4746,10 @@ > else if ((pat[0] == '.' && (vim_ispathsep(pat[1]) > || (pat[1] == '.' && vim_ispathsep(pat[2]))))) > path = (char_u *)"."; > - else > - path = vim_getenv((char_u *)"PATH", &mustfree); > + else { > + if ((path = vim_getenv((char_u *)"PATH", &mustfree))) > + path = ""; > + }
This unilateraly replaces the value of $PATH, when it has one, with "". Instead of this change (which should have included an == NULL check), why not add a != NULL check in the following for loop? Attached patch includes that update. -- James GPG Key: 1024D/61326D40 2003-09-02 James Vega <james...@jamessan.com>
diff --git a/src/ex_getln.c b/src/ex_getln.c --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -4754,7 +4754,7 @@ * collect them in "ga". */ ga_init2(&ga, (int)sizeof(char *), 10); - for (s = path; *s != NUL; s = e) + for (s = path; s != NULL && *s != NUL; s = e) { if (*s == ' ') ++s; /* Skip space used for absolute path name. */ diff --git a/src/os_win32.c b/src/os_win32.c --- a/src/os_win32.c +++ b/src/os_win32.c @@ -232,7 +232,7 @@ * "!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 < MAXPATHL) { STRCPY(temp, p); STRCAT(temp, ";");
signature.asc
Description: Digital signature