summaryrefslogtreecommitdiff
path: root/src/misc1.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2012-07-06 16:49:40 +0200
committerBram Moolenaar <Bram@vim.org>2012-07-06 16:49:40 +0200
commitbef4790c236327ebb77cd438d49ac9b8e7dc6542 (patch)
treebbb6e766e134977f234bd5fa39fb4e4f01695e23 /src/misc1.c
parent756287da38076a25fda0ecb75254ef75afb9c931 (diff)
downloadvim-git-bef4790c236327ebb77cd438d49ac9b8e7dc6542.tar.gz
updated for version 7.3.589v7.3.589
Problem: Crash when $HOME is not set. Solution: Check for a NULL pointer. (Chris Webb)
Diffstat (limited to 'src/misc1.c')
-rw-r--r--src/misc1.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/misc1.c b/src/misc1.c
index 99881dccd..348227206 100644
--- 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);