aboutsummaryrefslogtreecommitdiff
path: root/server.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-08-31 11:37:27 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-08-31 11:37:27 +0000
commit71ede76c68104c43a9f6980564fb6283a7f19473 (patch)
tree06c391e5791d700d76b59c5dd3aa2a187c5a66c6 /server.c
parent2e5b3ab8bc0e0f7a36f7a901263fa720654d60ca (diff)
downloadrtmux-71ede76c68104c43a9f6980564fb6283a7f19473.tar.gz
rtmux-71ede76c68104c43a9f6980564fb6283a7f19473.tar.bz2
rtmux-71ede76c68104c43a9f6980564fb6283a7f19473.zip
Don't call tty_free unless the client is a terminal, otherwise tty_init hasn't
been called and it may end up doing close(0). From Kalle Olavi Niemitalo.
Diffstat (limited to 'server.c')
-rw-r--r--server.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/server.c b/server.c
index 3f15ca41..0780e6b1 100644
--- a/server.c
+++ b/server.c
@@ -915,7 +915,12 @@ server_lost_client(struct client *c)
}
log_debug("lost client %d", c->ibuf.fd);
- tty_free(&c->tty);
+ /*
+ * If CLIENT_TERMINAL hasn't been set, then tty_init hasn't been called
+ * and tty_free might close an unrelated fd.
+ */
+ if (c->flags & CLIENT_TERMINAL)
+ tty_free(&c->tty);
screen_free(&c->status);