summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2013-10-05 10:40:50 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2013-10-05 10:40:50 +0000
commit0beaad422a9168bdd80b1e6475d2c91ca8dd0dab (patch)
tree58ecc9ce23dfbdda5347a60e44693811f733c41c /usr.bin/tmux
parent38f5e5f3973c4ee9eb77d669c868edfd6fc45faa (diff)
Fix previous not to leak fd on failure, whoops.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/tmux.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index efa5ed3e365..597d2ea0799 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.121 2013/10/05 08:12:39 nicm Exp $ */
+/* $OpenBSD: tmux.c,v 1.122 2013/10/05 10:40:49 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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