diff options
author | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2015-01-22 20:20:15 +0000 |
---|---|---|
committer | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2015-01-22 20:20:15 +0000 |
commit | 12b813b5895cae579e403dafe43878868f27fe0f (patch) | |
tree | aafceebff5feeaa2f76b0e7f59dd1e479464c7ab /Src/utils.c | |
parent | 99f42d8ce022645dfc38b8e06d25ab281e995cf9 (diff) | |
download | zsh-12b813b5895cae579e403dafe43878868f27fe0f.tar.gz zsh-12b813b5895cae579e403dafe43878868f27fe0f.tar.xz zsh-12b813b5895cae579e403dafe43878868f27fe0f.zip |
34331: better handling of NULL in cd.
Problem was return from symbolic link expander in weird cases where there file system isn't behaving itself properly.
Diffstat (limited to 'Src/utils.c')
-rw-r--r-- | Src/utils.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Src/utils.c b/Src/utils.c index 4561b5e9a..cf18f1240 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -1108,10 +1108,13 @@ getnameddir(char *name) if ((pw = getpwnam(name))) { char *dir = isset(CHASELINKS) ? xsymlink(pw->pw_dir) : ztrdup(pw->pw_dir); - adduserdir(name, dir, ND_USERNAME, 1); - str = dupstring(dir); - zsfree(dir); - return str; + if (dir) { + adduserdir(name, dir, ND_USERNAME, 1); + str = dupstring(dir); + zsfree(dir); + return str; + } else + return ztrdup(pw->pw_dir); } } #endif /* HAVE_GETPWNAM */ |