diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-10-05 11:40:47 +0100 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-10-05 11:40:47 +0100 |
commit | 710eeb2a33cb91c05251c69d7eb1a572aed44cb4 (patch) | |
tree | b1db48ce44b88425c1f56635435bf9d86715318a | |
parent | 3493b7dac7785a1675a2fc70e37c4461bb18043c (diff) | |
download | rtmux-710eeb2a33cb91c05251c69d7eb1a572aed44cb4.tar.gz rtmux-710eeb2a33cb91c05251c69d7eb1a572aed44cb4.tar.bz2 rtmux-710eeb2a33cb91c05251c69d7eb1a572aed44cb4.zip |
Fix previous not to lead fd on failure.
-rw-r--r-- | tmux.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -130,23 +130,25 @@ areshell(const char *shell) const char * get_full_path(const char *wd, const char *path) { - int fd; - static char newpath[MAXPATHLEN]; + int fd; + static char newpath[MAXPATHLEN]; + const char *retval; fd = open(".", O_RDONLY); if (fd == -1) return (NULL); - if (chdir(wd) != 0) - return (NULL); - if (realpath(path, newpath) != 0) - return (NULL); + retval = NULL; + if (chdir(wd) == 0) { + if (realpath(path, newpath) == 0) + retval = newpath; + } if (fchdir(fd) != 0) chdir("/"); close(fd); - return (newpath); + return (retval); } void |