mirror of
https://github.com/tmux/tmux.git
synced 2024-11-16 01:18:52 +00:00
Fix previous not to lead fd on failure.
This commit is contained in:
parent
3493b7dac7
commit
710eeb2a33
16
tmux.c
16
tmux.c
@ -130,23 +130,25 @@ areshell(const char *shell)
|
|||||||
const char *
|
const char *
|
||||||
get_full_path(const char *wd, const char *path)
|
get_full_path(const char *wd, const char *path)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
static char newpath[MAXPATHLEN];
|
static char newpath[MAXPATHLEN];
|
||||||
|
const char *retval;
|
||||||
|
|
||||||
fd = open(".", O_RDONLY);
|
fd = open(".", O_RDONLY);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
if (chdir(wd) != 0)
|
retval = NULL;
|
||||||
return (NULL);
|
if (chdir(wd) == 0) {
|
||||||
if (realpath(path, newpath) != 0)
|
if (realpath(path, newpath) == 0)
|
||||||
return (NULL);
|
retval = newpath;
|
||||||
|
}
|
||||||
|
|
||||||
if (fchdir(fd) != 0)
|
if (fchdir(fd) != 0)
|
||||||
chdir("/");
|
chdir("/");
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return (newpath);
|
return (retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user