mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-09-28 15:01:21 +02:00
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.
This commit is contained in:
parent
99f42d8ce0
commit
12b813b589
@ -1,3 +1,8 @@
|
||||
2015-01-22 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* 34331: Src/builtin.c, Src/utils.c: don't trip over
|
||||
NULL pointer in cd in rare cases where file system goes AWOL.
|
||||
|
||||
2015-01-22 Barton E. Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 34344: Test/V07pcre.ztst: fix 34338, builtins need loading too
|
||||
|
@ -1156,9 +1156,11 @@ cd_new_pwd(int func, LinkNode dir, int quiet)
|
||||
zsfree(getlinknode(dirstack));
|
||||
|
||||
if (chasinglinks) {
|
||||
s = new_pwd;
|
||||
new_pwd = findpwd(s);
|
||||
zsfree(s);
|
||||
s = findpwd(new_pwd);
|
||||
if (s) {
|
||||
zsfree(new_pwd);
|
||||
new_pwd = s;
|
||||
}
|
||||
}
|
||||
if (isset(PUSHDIGNOREDUPS)) {
|
||||
LinkNode n;
|
||||
|
11
Src/utils.c
11
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user