Fix previous not to leak fd on failure, whoops.

This commit is contained in:
nicm 2013-10-05 10:40:49 +00:00
parent 3d8a8ea0c6
commit 9f330897a8

12
tmux.c
View File

@ -129,21 +129,23 @@ 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