summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2014-01-09 21:20:45 +0000
committernicm <nicm@openbsd.org>2014-01-09 21:20:45 +0000
commitc38c88fd5c5d81d428c2376061e79b2e8a1ac844 (patch)
tree8cdc853febbf437d7b121d4586c3a28f9ef402eb /usr.bin
parentsync usage(); (diff)
downloadwireguard-openbsd-c38c88fd5c5d81d428c2376061e79b2e8a1ac844.tar.xz
wireguard-openbsd-c38c88fd5c5d81d428c2376061e79b2e8a1ac844.zip
Fix a memory/fd leak reported by Tiago Cunha.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/client.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c
index 0d0aeac405d..5b4d8eeca31 100644
--- a/usr.bin/tmux/client.c
+++ b/usr.bin/tmux/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.77 2014/01/09 14:05:55 nicm Exp $ */
+/* $OpenBSD: client.c,v 1.78 2014/01/09 21:20:45 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -118,10 +118,15 @@ retry:
close(fd);
xasprintf(&lockfile, "%s.lock", path);
- if ((lockfd = client_get_lock(lockfile)) == -1)
+ if ((lockfd = client_get_lock(lockfile)) == -1) {
+ free(lockfile);
goto retry;
- if (unlink(path) != 0 && errno != ENOENT)
+ }
+ if (unlink(path) != 0 && errno != ENOENT) {
+ free(lockfile);
+ close(lockfd);
return (-1);
+ }
fd = server_start(lockfd, lockfile);
free(lockfile);
close(lockfd);