about summary refs log tree commit diff
path: root/Src/utils.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2015-01-22 20:20:15 +0000
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2015-01-22 20:20:15 +0000
commit12b813b5895cae579e403dafe43878868f27fe0f (patch)
treeaafceebff5feeaa2f76b0e7f59dd1e479464c7ab /Src/utils.c
parent99f42d8ce022645dfc38b8e06d25ab281e995cf9 (diff)
downloadzsh-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.c11
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 */