Mercurial > vim
changeset 3658:e82937b753a8 v7.3.589
updated for version 7.3.589
Problem: Crash when $HOME is not set.
Solution: Check for a NULL pointer. (Chris Webb)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 06 Jul 2012 16:49:40 +0200 |
parents | e024aadde309 |
children | 22ab3555bf83 |
files | src/misc1.c src/version.c |
diffstat | 2 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/misc1.c +++ b/src/misc1.c @@ -4496,8 +4496,12 @@ home_replace(buf, src, dst, dstlen, one) #else homedir_env_orig = homedir_env = mch_getenv((char_u *)"HOME"); #endif + /* Empty is the same as not set. */ + if (homedir_env != NULL && *homedir_env == NUL) + homedir_env = NULL; + #if defined(FEAT_MODIFY_FNAME) || defined(WIN3264) - if (vim_strchr(homedir_env, '~') != NULL) + if (homedir_env != NULL && vim_strchr(homedir_env, '~') != NULL) { int usedlen = 0; int flen; @@ -4513,8 +4517,6 @@ home_replace(buf, src, dst, dstlen, one) } #endif - if (homedir_env != NULL && *homedir_env == NUL) - homedir_env = NULL; if (homedir_env != NULL) envlen = STRLEN(homedir_env);