summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm>2013-10-05 10:40:49 +0000
committernicm <nicm>2013-10-05 10:40:49 +0000
commit9f330897a8fc4f927d355eacf9cc58f3be2092f7 (patch)
tree7fb81411be1e697a4f5916577e0aa7971b9abc0b
parent3d8a8ea0c68d6ab343568559f7d5879170c2e78c (diff)
Fix previous not to leak fd on failure, whoops.
-rw-r--r--tmux.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/tmux.c b/tmux.c
index 8726a55f..73843a96 100644
--- a/tmux.c
+++ b/tmux.c
@@ -127,23 +127,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